Skip to main content

Bug Tracker

Side navigation

#4385 closed bug (invalid)

Opened March 19, 2009 12:22PM UTC

Closed August 09, 2009 01:39AM UTC

Last modified April 04, 2011 11:10AM UTC

insertAfter loses script tags

Reported by: bryan_larsen Owned by:
Priority: major Milestone: 1.4
Component: unfiled Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:
Description

If I clone some html that includes a script tag, the script gets

cloned. However, if I then do an insertAfter() with that clone, the

script tag gets lost.

Example (using jquery-1.3.2):

<div id="clone_me">

<script> ({option_a: 17}); </script>

<span>Hello</span>

</div>

<button onclick="jQuery('#clone_me').clone(true).insertAfter(jQuery(this));">

click me </button>

jQuery('#clone_me').clone(true).find('script').text() ->

"({option_a: 17});"

jQuery('#clone_me').clone(true).insertAfter(jQuery(this)).find

('script').text() -> ""

Tested with firefox 3.0.7

Attachments (0)
Change History (4)

Changed March 21, 2009 01:52AM UTC by dmethvin comment:1

Why do you want the actual script tag to remain? jQuery needs to be careful with leaving the script tags in because it doesn't want to execute the scripts multiple times.

Changed August 09, 2009 01:39AM UTC by dmethvin comment:2

resolution: → invalid
status: newclosed

Closed-inactive.

Changed December 21, 2010 05:14PM UTC by anonymous comment:3

Not all script tags contain code... e.g. JQuery Templates

Changed April 04, 2011 11:10AM UTC by anonymous comment:4

true.

Jquery API seems to destroy jquery templates in lots of circumstances, if one wraps them in script tags as per the documentation, resulting in strange errors.