I may misunderstand your question, but you can always wait until the
window loads:
Event.observe(window, 'load',
function()
{
Event.observe('frm', 'submit', handler);
}
);
On Jan 23, 10:16 am, Ken Snyder <[EMAIL PROTECTED]> wrote:
> Michael Sharman wrote:
> > Hi Justin,
>
> >> You should not be attempting to attach events to elements that are not on
> >> the page
>
> > The code is in an external .js file and there are only a couple of
> > pages where that element doesn't appear.
>
> >> var elem = $('frm');
>
> > I guess I can't do that though as $('frm') won't exist and throw an
> > error. Remember that this code exists in the 'onload' code block.
>
> Why CAN'T you do it? If you need to keep the error console clean, use a
> try-catch block.
>
> try { $('frm').observe('submit', handler); } catch (e) {}
>
> - Ken Snyder
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---