Skip to main content

Search and Top Navigation

#3677 closed bug (wontfix)

Opened December 19, 2008 03:07AM UTC

Closed October 25, 2012 02:36AM UTC

Javascripts re-execute on show/hide

Reported by: dmethvin Owned by:
Priority: major Milestone: 1.10.0
Component: ui.effects.core Version: 1.6rc2
Keywords: Cc:
Blocked by: Blocking:

Referred from

If the content being hidden has an embedded script tag, the script is executed a second time. Test case attached using slide effect.

Attachments (3)
  • alert.js (0.0 KB) - added by dmethvin December 19, 2008 03:08AM UTC.

    Sample script to embed in hidden content

  • jquery-ui-1.6rc2.js (30.8 KB) - added by dmethvin December 19, 2008 03:08AM UTC.

    UI 1.6rc2 with slide effect

  • ui-script-rerun.html (1.0 KB) - added by dmethvin December 19, 2008 03:07AM UTC.

    Test case main

Change History (14)

Changed December 19, 2008 03:16AM UTC by dmethvin comment:1

This may be due to .

Changed December 31, 2008 05:41PM UTC by rdworth comment:2

component: ui.coreeffects.core

Changed December 31, 2008 05:41PM UTC by rdworth comment:3

milestone: TBD1.6
priority: minormajor

Changed March 08, 2009 02:43PM UTC by rdworth comment:4

milestone: 1.71.8

Changed August 19, 2010 04:46AM UTC by bencoe comment:5

I think is caused by domManip() in association with $.wrap in jquery. When a new element is appended to the dom a stack of scripts to execute is created and evaluated. wrap() uses append() which calls domManip() which re-executes script tags. My thought is that createWrapper() in jquery.effects.core could potentially tear out script tags (these are torn out later on anyways). My assumption being that effects should be executed on visible elements, which means their scripts will already have been executed.

Any ways, here is my potential fix:

Changed August 21, 2010 06:44AM UTC by bencoe comment:6

This actually provides a better fix in my opinion:

it checks to make sure the element has document as its parent before trying to remove the script tag. I think a better ultimate fix would be in the jquery core probably.

Changed August 22, 2010 07:04AM UTC by bencoe comment:7

I've also patched this issue in jQuery... Which might be a more logical place to fix the problem. Basically, wrap() currently causes a script to execute a second time ... note that scripts are already stripped from the page after execution, making this fix less insane than it looks ;)

Changed August 27, 2010 12:25PM UTC by scottgonzalez comment:8

Thanks for the pataches ben. We're trying to figure out how to properly handle this in core. The problem exists with more than just .wrap(). See for the underlying problem.

Changed March 27, 2011 01:35PM UTC by gnarf comment:9

#4839 is a duplicate of this ticket.

Changed March 28, 2011 06:04PM UTC by gnarf comment:10

status: newopen

Changed April 26, 2012 02:16PM UTC by scottgonzalez comment:11

#8278 is a duplicate of this ticket.

Changed July 25, 2012 05:41PM UTC by scottgonzalez comment:12

#8460 is a duplicate of this ticket.

Changed October 11, 2012 02:42PM UTC by scottgonzalez comment:13


Changed October 25, 2012 02:36AM UTC by mikesherov comment:14

resolution: → wontfix
status: openclosed

This will be fixed in core in jquery 1.9 here: