Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10866 closed bug (invalid)

My elements are losing attached data once the DOM loads

Reported by: [email protected] Owned by:
Priority: low Milestone: None
Component: data Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:


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!

Change History (5)

comment:1 Changed 11 years ago by [email protected]

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

comment:2 Changed 11 years ago by anonymous

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

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

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?

comment:3 Changed 11 years ago by timmywil

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.

comment:4 Changed 11 years ago by Jai

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.

comment:5 Changed 11 years ago by Jai

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

Note: See TracTickets for help on using tickets.