Moving a DOM element containing a dynamically created script tag

I use the Fish gadget ( http://abowman.com/google-modules/fish/ ) as part of a wiki-based CMS and I need to move the gadget from one HTML element to another. (Note: the fish gadget is an example - a problem occurs with other gadgets.)

If I directly reinstall the gadget using the ig_reset base gadget class, then everything works. If I try to reposition using the circumference shell, then the iframe used by the gadget seems to take over. Unfortunately, I need the flexibility of moving around using a circumference shell.

This seems to be related to moving the SCRIPT tag in the DOM. The gadget dynamically creates a SCRIPT and style tag. If I remove the dynamically created SCRIPT tag from the DOM and then move the wrapper to another location in the DOM, everything will work fine. If I try to move the SCRIPT tag to another DOM element, then the original problem occurs. Therefore, moving the SCRIPT tag around the DOM seems to be the reason - regardless of when the movement occurs (even after loading).

I would like to understand what is happening here to make the frame capture the page, and also to find a better solution than removing the dynamically created SCRIPT tag.

I put a test here: http://solidgone.com/jquery/google-gadget.html - the demo uses jQuery, but I don’t think it is related to jQuery ...

+5
2

, script , jQuery, . , ig_reset ( - no script) . , script - script, .

jQuery, , .

+16

, jQuery. ,

$("#with-wrapper").click(function () 
{
   $('.sidebar-content-wrapper').contents().appendTo($("#sidebar"));
});

, jQuery :

$("#with-wrapper").click(function() 
{
   var sidebar = $("#sidebar")[0];
   $('.sidebar-content-wrapper').contents().each(function()
   { 
      // raw DOM method rather than jQuery 
      //  appendTo() -> domManip() -> execute script blocks behavior
      sidebar.appendChild(this);
   });
});
+5

All Articles