I'm primarily using Insertion.Bottom and don't see how to use the traversal methods because I don't know when I've reached the last element. I really don't know anything about the element being inserted. It's an HTML snippet returned from the server. Any ideas?
-----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Colin Mollenhour Sent: Sunday, February 25, 2007 3:25 AM To: [email protected] Subject: [Rails-spinoffs] Re: Get Newly Inserted Element There are many ways but which is best in your case depends on how much knowledge you have of what is being inserted and where you are inserting it. Probably the best bet is to use Prototype's DOM traversal methods. Element.next/previous/up/down are good because they don't select text nodes and if you know what you are looking for you can use CSS rules with them to find it easily. http://prototypejs.org/api/element/methods/next With Insertion.Bottom, if you are inserting more than one new element you may need to store a reference to the old lastChild and then call Element.next on it. var oldLast = element.lastChild; new Insertion.Bottom(element,content); //or new Insertion.After(oldLast,content); var firstNew = Element.next(oldLast); All of the other cases should be very straightforward. E.g. if Top use down, if After use next, if Before use previous Colin Daniel Eben Elmore wrote: > I'm using the Insertion object and need to get the element just inserted. > The object appears to just return the parent object used. How can I get the > new element? > > > Thanks! > Daniel > > > > > > . > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
