Side navigation
#5841 closed bug (invalid)
Opened January 17, 2010 06:58PM UTC
Closed November 19, 2010 05:45AM UTC
Race condition (sync/async) bug in remove
Reported by: | PSS | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.4.1 |
Component: | core | Version: | 1.4 |
Keywords: | remove html race | Cc: | |
Blocked by: | Blocking: |
Description
I have html
<div id ="something">
something something something something something something
<div id="somethingelse">somethingelse</div>
something something something something something something
</div>
Then I slideToggle and then remove one div and copy parent contents to variable:
jQuery(document).ready(function() {
jQuery('div#somethingelse').slideToggle(1500, function () { jQuery(this).remove(); });
content_text = jQuery('div#something').html();
jQuery('div#something').after('<hr>' + content_text)
});
As result the variable content_text has data BEFORE slidetoggle + removal. Wrong.
This works:
jQuery(document).ready(function() {
jQuery('div#somethingelse').remove();
content_text = jQuery('div#something').html();
jQuery('div#something').after('<hr>' + content_text)
});
Is that as intended or a bug?
This does not work either:
jQuery(document).ready(function() {
var content_text = "nothing";
jQuery('div#somethingelse').slideToggle(1500, function () { jQuery(this).remove(); content_text = jQuery('div#something').html(); });
//jQuery('div#somethingelse').remove();
jQuery('div#something').after('<hr>' + content_text)
});
Attachments (0)
Change History (2)
Changed January 17, 2010 07:05PM UTC by comment:1
Changed November 19, 2010 05:45AM UTC by comment:2
resolution: | → invalid |
---|---|
status: | new → closed |
Thanks for the report, but this is not a jQuery bug. The callback passed to slideToggle
is executed asynchronously; this is how JavaScript works. You cannot do what you are trying to do. Please use the jQuery Forum for support requests.
Trying some code formatting here...