PrototypeHelper
The Prototype JavaScript library simplifies many common Ajax tasks, but these helper methods make it even more convenient to incorporate calls to Prototype in Rails templates:
evaluate_remote_response
Evaluates the JavaScript response from a remote service using the JavaScript
eval
method. Theeval
method opens JavaScript applications up to attack, so be certain that what youâre processing is free of potentially harmful code.form_remote_for
Same as
remote_form_for
, described later.form_remote_tag
Creates a
form
element that uses anXmlHttpRequest
call to submit form data. This allows the page to handle the response rather than reloading an entirely new page.link_to_remote
Creates a link that issues an
XmlHttpRequest
call, again allowing the page to handle the response rather than replacing the current page with a new destination.observe_field
Watches the content of a given field and makes a remote call (or a JavaScript function call) when the content of that field changes. Useful for components like text fields that provide suggestions.
observe_form
Watches the content of a given form and makes a remote call (or a JavaScript function call) when the content of that field changes.
periodically_call_remote
Makes an
XmlHttpRequest
call every so often, according to a duration specified in seconds set as the:frequency
option.remote_form_for
Works like
form_for
, except that submitting the form triggers anXmlHttpRequest
call that gets handled by Ajax in the browser instead of the ...
Get Learning Rails: Live Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.