Hi all,
  This might be a more generic browser/javascript questions than a
prototype specific quesiton but i thought it would better to ask here
because you all tend to really understand javascript and browsers in a
ton of detail. So here goes.

If i execute the following code:


<div id="area"></div>


$('area').insert({bottom: "<div id="inserted"></div>"});

var count = 0;
var f = function() {
      if ($('inserted') == null) {
            console.log("not there");
            if (count > 50) {
                  $('area'.insert({bottom: "<div id="inserted"></
                  count = 0;
      } else {



Most of the time it just shows:

>> there

but some of the time it does this

>> not there
>> not there
>> not there
>> there

I am assuming because the insert is something that is queued and the
browser then inserts the nodes into the DOM in its next event loop. I
know that webkit is a single threaded so this makes sense that
sometimes its not there and then it gets there, so really i guess i
have to wait till its there before i can do the "next thing" on that
inserted node. What about firefox and IE? Are they all single threaded
in the same way? What happens in Chrome?

Sometimes i see the following happen also which is really concerning
to me:

>> not there
>> not there
>> ... 50 times
>> not there
>> there

It happens every so often on webkit (mac os) and on iPhone webkit and
i can reproduce it pretty easily. I have built something simple that
will do this but all this seems a little crazy to me because when i
look at others code they dont even take this into account. They never
way for DOM elements to show up when inserting HTML text into a DOM

Any answers/suggestions would be super helpful.


You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to