Newer Version Available
Updating Records with Remote Objects
Update records by calling update() on a Remote Objects model instance.
update() accepts three
arguments, all optional, and can update one or many records at the
same time, depending on the arguments that you provide.
record_ids is an array of strings, where the strings are
the Ids of records to be updated. If this
parameter is omitted, the Id that is set on the
Remote Object instance is used. The simplest way to update a record is to call update() on
itself.
More often, you might need to update a record in response to a form submission. Updating the
record can be as simple as reading some form values, including the record’s
Id, and passing the values to update(). For
example:
Robust code includes a callback to handle errors. The following
code accomplishes the same as the previous sample, altered to use
an event handler and a callback function.
You can update many records at the same time, as long as the update
to be performed is uniform, that is, the same for every record. For
example, you might need to update a collection of checked items from
a list, to change a status field to “Archived” or a
current timestamp. To update records in one request, pass an array
of Ids to update(). The fields to be updated
can be set as part of the Remote Object model itself, but it’s
safer to pass them directly to update(), like this: