Backbone.js Patterns and Best Practices by 2014

Backbone.js Patterns and Best Practices by 2014

Author:2014
Language: eng
Format: mobi
Publisher: Packt Publishing


Performing data operations with collections

You can use AJAX requests to save and fetch data to and from the server. The result then needs to be applied on the collection. However, Backbone simplifies the complete process by providing a few methods such as fetch() and save() to directly interact with the server. We will use the same collection that we used in the previous section to demonstrate how we can perform all data operations with collections.

Fetching data from the server

Fetching data from the server is quite easy. You just call the fetch() method on the collection as shown in the following code line, and a GET request is sent to the URL that we added in the collection's configuration. It receives a JSON array with objects that get added to the collection as models.

users.fetch();



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.