Skip to main content

Bug Tracker

Side navigation

#10866 closed bug (invalid)

Opened November 22, 2011 09:28PM UTC

Closed November 22, 2011 10:34PM UTC

Last modified December 22, 2011 06:29AM UTC

My elements are losing attached data once the DOM loads

Reported by: songofchrist@hotmail.com Owned by:
Priority: low Milestone: None
Component: data Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:
Description

I have tested my code in Chrome, IE8, and in Firefox. In the former two, it works fine. In the latter, for some reason, the data that I've associated with elements is getting lost, and it's breaking my menu. It's very odd. I placed a script at the very end of the document, just before the closing body tag and checked all of the elements for the data. All of it was there. Then I copied the exact same statement and set it to execute 1ms later. All of a sudden, the data had disappeared. It would appear that, merely by virtue of the DOM having finished loading, all the data was lost.

Now I do have two onready functions that I'm executing and I suspected that maybe I was changing something unintentionally via these. I performed the same sort of test in each of these. The data is present at the end of each onready function, but disappears thereafter. The fact that the same code works perfectly in two other major browsers makes me think that it's not my code. It's something to do with Firefox, a bug of some kind, or something to do with the way data() is storing things that doesn't agree with Firefox.

Any ideas? Any help is much appreciated!

Attachments (0)
Change History (5)

Changed November 22, 2011 09:36PM UTC by songofchrist@hotmail.com comment:1

BTW, I recently upgraded to Firefox 8. That very well may have something to do with it.

Changed November 22, 2011 10:26PM UTC by anonymous comment:2

Okay, so I've done a bit more to try to isolate the problem. I reduced everything to the following simple html page:

<html>
<head>
	<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<script type="text/javascript">
	$('body').data( 'testit' , 1234 );
	alert( $( 'body' ).data('testit') );
	setTimeout( function() {
		alert( $( 'body' ).data('testit') );
	} , 1000 );
</script>
</body>
</html>

In Chrome and IE9, this works as expected. The data is attached to the body. Then you get one alert of 1234 immediately and another one second later. In Firefox 8, however, you get the first alert only. The second returns undefined. So clearly it's not my code (whew!) but rather something funky going on between Firfox and jQuery. Any ideas what's going on here?

Changed November 22, 2011 10:34PM UTC by timmywil comment:3

component: unfileddata
priority: undecidedlow
resolution: → invalid
status: newclosed

Unfortunately, we are unable to assist with issues related to support, jQuery UI, or third party plugins. Support can be found on the forums or on the #jquery irc channel. Bug reports related to jQuery UI can be filed on the jQuery UI bug tracker. Issues with third-party plugins should be filed with the corresponding plugin issue tracker, usually available on http://github.com.

Changed December 22, 2011 05:55AM UTC by Jai comment:4

I have this same bug. This is not about the dom loading, but about the dom being modified after data is set, and then the data disappears. For me this bug occurs in FF 8 but not in Chrome.

Changed December 22, 2011 06:29AM UTC by Jai comment:5

I take that comment back - I can't reproduce this, my issue is caused by something else.