Bug Tracker

Modify

Ticket #4385 (closed bug: invalid)

Opened 4 years ago

Last modified 2 years ago

insertAfter loses script tags

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

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

Change History

comment:1 Changed 4 years ago by dmethvin

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.

comment:2 Changed 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

Closed-inactive.

comment:3 Changed 2 years ago by anonymous

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

comment:4 Changed 2 years ago by anonymous

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.