spez86
spez86

Reputation: 732

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/

Upvotes: 3

Views: 2783

Answers (2)

spez86
spez86

Reputation: 732

Had to get around this by throwing the cloned object into a another div, hiding that div, and then appending its contents each time. Annoying and makes for longer code, but it's about the only thing that works right now.

Upvotes: 0

JoshNaro
JoshNaro

Reputation: 2097

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());

Upvotes: 1

Related Questions