When a script node is inserted into the document it is also executed (by
jQuery). To avoid re-executing it later (this happens a lot, as it turns
out) the script is simply removed from the document.

Naturally, this causes some issues when you actually want to see the
contents of the script element (as you do). However I think the trade-off is
better in this case.

The one alternative solution that I can think of is to use the internal
.data() API to attach information to the script element, informing it that
shouldn't be executed again at a later time. I'm not sure how unexpected
that is, though.

--John


On Mon, Aug 10, 2009 at 5:45 AM, Kof <oleg...@googlemail.com> wrote:

>
> Does anybody know why jQuery removes script tags added to body ?
>
> The problem is if you want to insert dom elements after the own script
> tag you can't select the script node any more, because it was removed
> by jquery.
>
> It is important by widgets because if I insert dynamically a script
> tag and the widget is using document.write - the whole document will
> be overwritten.
>
> So I want to insert widget html code after original script tag by
> using insertAfter instead of document.write.
>
> Of course I could also isert any div and then access it to insert the
> widget code, it is just not so pretty.
>
> I think jquerys domManip method shouldn't remove original script tag,
> or it should be possible to add parameter to avoid this.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to