Side navigation
#14259 closed bug (wontfix)
Opened August 15, 2013 04:30PM UTC
Closed August 21, 2013 03:49PM UTC
script not eval when using append code block in ajax loaded text
Reported by: | skovalev | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 2.0.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
when I'm using append twice(in ajax loaded text)some inserted scripts not called,
in example bellow, if I using ajax call to add this code block and alert(1) will never call, it was already cached on previous append.
<script> alert(2) $(function() { $("#test").appendTo($("#test2")) }) </script> <div id="test"> test1 <script> alert(1) </script> </div> <div id="test2"> test2 </div>
if i used jquery 1.7.2 alert will call as expected http://jsfiddle.net/WZwME/3/
Problem what I found is in this line
if ( rscriptType.test( node.type || "" ) && !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) )
line !data_priv.access( node, "globalEval" ) returns false
Attachments (0)
Change History (4)
Changed August 20, 2013 06:04PM UTC by comment:1
resolution: | → notabug |
---|---|
status: | new → closed |
Changed August 21, 2013 08:41AM UTC by comment:2
But now it ever not been executed. Could you call script at least one time, or explain me why alert(1) not been called in example?
Ps. If I remove appendTo alert would call as expected
Compare this code below, please
Thanks
Changed August 21, 2013 03:47PM UTC by comment:3
resolution: | notabug |
---|---|
status: | closed → reopened |
The first code block manipulates the second code block, the .appendTo()
runs immediately since the document is ready. jQuery's assumption is that since the code is already in the document it was run when the page loaded.
Your code is just too tricky, I don't think we want to sanction doing something like this and try to create defined behavior out of it. The API documentation does not create an expectation something like this should work.
Changed August 21, 2013 03:49PM UTC by comment:4
resolution: | → wontfix |
---|---|
status: | reopened → closed |
This is intentional, otherwise scripts are executed multiple times. The old behavior was a bug.