> remote_function generates the javascript for making an ajax request.
Although you could certainly use remote_function helper to achieve the
effect you want, if you are manipulating the DOM with your AJAX call you
must ensure that the DOM has been loaded before you AJAX call occurs.
I prefer to do this using an unobtrusive JavaScript technique as
explained in the Prototype documentation:
http://www.prototypejs.org/api/event/observe
Event.observe(window, ''load'', function() {
Event.observe(''signinForm'', ''submit'',
checkForm);
});
The important line from the example above is the first line. It creates
a function that is executed after the page is fully loaded. The
documentation goes on to explain that observing the window''s load event
waits for the entire page to load, rather than executing just after the
DOM has been fully loaded. This could be an issue if your page is
complex and has a lot of images and other resources to load. There is a
link to a blog that explains how to solve that if necessary.
Apparently JQuery has these workarounds built in already, but I''m only
scratching the surface of JQuery, so I''m not sure how well that works
in
all the various browsers. But, I''m guessing they have figured it out.
Frederick Cheung wrote:> On Oct 2, 4:39�pm, Tim Conner
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
> wrote:
>> I want to run an Ajax call but I don''t want to do it through a
link
>> (link_to_remote), through a form (form_remote_tag) or periodically
>> (periodically_call_remote). �I just want to make the call once and I
>> want to happen automatically after the page has finished loading.
�I''d
>> like to write this using the prototype helpers, what helper do I need
to
>> use?
>
> remote_function generates the javascript for making an ajax request.
>
> Fred
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---