API Prototype

Page 32

Unregister: remember the reference… As always, unregistering something requires you to use the very same object you used at registration. So if you plan on unregistering a responder, be sure to define it first, then pass the reference to register, and finally, when the time comes, to unregister.

Ajax.Updater new Ajax.Updater(container, url[, options])

Performs an AJAX request and updates a container’s contents based on the response text. Ajax.Updater is a specialization of Ajax.Request: everything about the latter is true for the former. If

you’re unfamiliar with Ajax.Request, go read its documentation before going ahead with this one.

A simple example new Ajax.Updater('items', '/items', { parameters: { text: $F('text') } });

Example 2.8.

A note about timing The onComplete callback will get invoked after the update takes place.

Additional options Since the goal of Ajax.Updater is specifically to update the contents of a DOM element (container) with the response text brought back by the AJAX request, it features a couple of new options, in addition to the common options set. These are: Option

Default

Description

evalScripts

false

This determines whether <script> elements in the response text are evaluated or not.

insertion

None

By default, Element.update is used, which replaces the whole contents of the

22 | Chapter 2. Ajax


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.