Good day,

I'm not sure if this is a bug with jQuery or how a browser handles the
request, so thought I would post here first instead of the bug
tracker.

The issue comes when you try and load jQuery dynamically through
creating the necessary DOM objects. Everything works fine as long as
you do not have a $(body).wrapInner("..."). It seems that it reloads
the content which in effect causes the jQuery to once again be loaded.

This may sound a bit confusing so have created a quick demonstration.
(Note: You will receive 4 Javascript alerts at first)

Demonstration: http://www.chrisjhill.co.uk/lab/js_wrapinner_bug/

1. The page loads.
2. Javascript will initially trigger a click event on the button.
3. The button has a onclick event which is triggered.
4. The button fires a alert("Hello from the button") and creates the
DOM elements loading jQuery.
5. The jQuery is loaded, firing a alert("Hello from jQuery").
6. The jQuery wraps a div in the body using $("body").wrapInner
("<div></div>");
7. This somehow causes the button to be clicked again, triggering the
whole process once more.

Things to note:

1. You can click the button and everything works as expected.
2. This only seems to happen when you send an event to the browser to
click the button.

Any help of this would be hugely appreciated, or a way to work around
the problem. If this is indeed a big with jQuery then I can post it on
the bug tracker.

Thanks very much,
Chris.

Reply via email to