Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery .clone() .html() in IE Bug

There seems to be a bug still present in jQuery 1.6.2 that has an issue with .clone() and .html(). I created a fiddle: http://jsfiddle.net/Vxyu3/12/ that should help explain the bug. If you click on both links one after another, in Firefox the content will flip back and forth with no problems. In IE however (particularly IE7) if you go to the fiddle and then hit "Show Dynamic Content" then "Show Clone" then "Show Dynamic Content" then "Show Clone", the clone content is no longer visible. In fact it's not even injected into the DOM. It's like it disappears, or get erased somewhere along the way... Has anyone come across this bug and where I would start about fixing the issue.

Thanks!

http://jsfiddle.net/Vxyu3/12/

like image 235
spez86 Avatar asked May 03 '26 02:05

spez86


1 Answers

May be a closure reference bug. Try defining the cloned parameter in global scope, but keep the assignment within the ready callback.

No, that doesn't work. It looks like a jQuery/IE bug where using a jQuery object for the HTML() function causes some problems.

Try this instead: domCloneMe.html(cloned.html());

like image 118
JoshNaro Avatar answered May 05 '26 16:05

JoshNaro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!