Hi Kiran, It sounds like you've already put together a minimalist test case, would you post it (e.g., to Pastie[1] or similar)? I haven't run into a situation where a single defer wasn't sufficient, but I also haven't tested extensively on Mac OS.
Cheers, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Oct 30, 7:19 am, phegaro <pheg...@gmail.com> wrote: > 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: > > HTML: > > <div id="area"></div> > > Javascript: > > $('area').insert({bottom: "<div id="inserted"></div>"}); > > var count = 0; > var f = function() { > if ($('inserted') == null) { > console.log("not there"); > count++; > if (count > 50) { > $('area'.insert({bottom: "<div id="inserted"></ > div>"}); > count = 0; > } > f.defer(); > } else { > console.log("there"); > } > > }; > > f(); > > Result: > > 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 > element. > > Any answers/suggestions would be super helpful. > > Kiran --~--~---------~--~----~------------~-------~--~----~ 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 prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---