Event delegation should do it:
document.observe('submit', function(e) {
if (e.target.hasClassName('validation-required')) {
if (!validateForm(e.target))
e.stop();
}
});
- kangax
On Apr 18, 5:31 pm, anathema <[EMAIL PROTECTED]> wrote:
> I sort of knew that was going to be the response. I should have
> mentioned it.
>
> The problem I see with that is, what if i have a bunch of stuff to
> observe? The code would become cluttered fast because I would be
> repeating myself everywhere. I need to come up with something that is
> reusable in multiple onCompletes and observes for multiple ID's.
>
> On Apr 18, 2:04 pm, kangax <[EMAIL PROTECTED]> wrote:
>
> > One of the options is to use an Ajax.Updater callback [1] to attach
> > observers once content is inserted into the DOM
> > ...
> > onComplete: function() {
> > ...
> > Event.observe('signinForm', 'submit', checkForm);
> > }
> > ...
>
> > [1]http://www.prototypejs.org/api/ajax/options
>
> > - kangax
>
> > On Apr 18, 4:21 pm, anathema <[EMAIL PROTECTED]> wrote:
>
> > > How do I make DOM elements available to my script after an
> > > Ajax.Updater? So for example I have this in my JS
>
> > > Event.observe('signinForm', 'submit', checkForm);
>
> > > Now let's say signinForm does not exist yet. It exists after an
> > > Ajax.Updater. How do I make my script aware that it is available now?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---