I wondered if something like that was happening, but then I thought I
read in the docs that getElementsBySelector added these to the
returned elements automatically.

On 23 Apr, 21:59, "Gareth Evans" <[EMAIL PROTECTED]> wrote:
> I wonder if when you do the newForm.update IE is dropping the prototype
> extensions on the elements and these are needed for the .first?
>
> Gareth
>
> On 4/23/07, ChrisT <[EMAIL PROTECTED]> wrote:
>
>
>
> > I'm having this problem with IE and getElementsBySelector, but am a
> > relative js novice, so quite possible -- likely even -- that I'm doing
> > something stupid. Either way, a fresh pair of eyes would help.
>
> > Basically I'm duplicating a fieldset within a form (so you can upload
> > more than one photo). [BTW, the fieldsets have a CSS id which relates
> > to the object id of the existing photo (the form is also used for
> > editing, so you need this so the user can replace replace them), or a
> > pseuo id of the form "n_0", "n_1", ...]
>
> > This is how I'm doing it (and I'm sure there must be a more elegant
> > way, but as I said, just a js novice):
>
> >        var mostRecentForm = $$('fieldset.photo_fields').last(); // get the
> > bottom fieldset
> >        var formNumber = mostRecentForm.id.replace('photo_fields_',''); //
> > find the photo' s object id from the fieldsets CSS id
> >        var rx = /n_\d/;
> >        var newFormNumber = rx.test(formNumber) ?
> > Number(formNumber.replace('n_','')) + 1 : 0 ; // if the id looks like
> > "n_?" then give it the next number, otherwise number it 0
> >        new Insertion.After(mostRecentForm, '<fieldset id="photo_fields_n_'
> > +
> > newFormNumber + '" class="photo_fields" style="display:none"></
> > fieldset>'); // add the new fieldset
> >        var newForm = $('photo_fields_n_' + newFormNumber); // find it and
> > make it into an Element
> >        newForm.update(mostRecentForm.innerHTML); // copy the contents of
> > the
> > existing fieldset into it
> >        //fails at this next line
> >        newForm.getElementsBySelector('legend').first().update("Photo " +
> > (Number(newFormNumber) + 1)); // update the legend
> >        newForm.getElementsBySelector('textarea', 'input[type="file"]',
> > 'input[type="text"]').each(function(s) {
> >                                        s.id = s.id.replace('photo_' +
> > formNumber, 'photo_n_' +
> > newFormNumber);
> >                                        s.name = s.name.replace('photo[' +
> > formNumber, 'photo[n_' +
> > newFormNumber);
> >                                        s.clear();}); //update the ids and
> > names of the fields
> >        currentPhotos = document.getElementsByClassName("current_photo",
> > newForm); // clear the contents
> >        new Effect.SlideDown(newForm); // show the new fieldset
>
> > On Firefox, Safari and Opera, this all works fine (though the
> > SlideDown is a bit jerky on FF). But on II (6 & 7) it fails on
> > newForm.getElementsBySelector('legend').first() -- Object doesn't
> > support this property or method. Note it actually fails on the
> > first(), not the getElementsBySelector.
>
> > Any suggestions? I've tried everything I can think of but am now
> > totally stumped.
>
> > Thanks
>
> > Chris


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to