You are correct. However I've discovered when it comes to working with web browsers correct and practical are often different, especially as long as we have to support IE 6.

I did try a dom based approach of cloning and inserting nodes to repeat them, setting the id before the insert, and it was slow and even more buggy under IE. I could use either dom techniques or regular expressions to ensure that all the ids are unique in the bits of innerHTML I am inserting. Again that would be slow (from what I've tried). So after I insert this less than ideal innerHTML with the duplicate ids, I find the new elements using childNodes, and make their ids unique. From all I have tried this has been the fastest approach. IE still sometimes puts the _extended attribute where it shouldn't be, and changing its value to a dummy function seems to keep that from happening.
I don't run my nodes through $() until I have made their ids unique.
Even using cloneNode and appendNode and changing the IDs beforehand (the academically correct way), I find ie often "entangles" nodes so that changing one affects an other, in a much worse way.

So I am limited by IE into a less than perfect solution, however this solution does work in all the browsers prototype supports, including the IE7 beta. This simple change lets prototype keep working consistently for me even in such less than perfect situations, and I don't really see any down side to it, if others are interested in using this small change.

On Apr 25, 2006, at 3:46 AM, Martin Bialasinski wrote:

On 4/25/06, Joseph Annino <[EMAIL PROTECTED]> wrote:

- Repeat a set of html code and inserts it as the innerHTML of an
element

Maybe because
after the repeating of the HTML, elements temporarily have the same id.

Never insert something into the DOM that results in IDs not being
unique. The browsers have to fall back into some recovery mode for
this error, the behaviour with duplicate IDs is undefined,
idiosyncratic and any hack is not future-proof. Avoid the situation.

You seem to loop after the insertion to change the ID. Either change
the IDs beforehand, or insert without IDs and set them on the loop.

Bye,
  Martin
_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to