Backbone. Sync-Synchronize models to servers

Source: Internet
Author: User

There are the following points:

1. The Sync method stores the model persistently on the server side. You can rewrite the implementation method of this method, which uses jquery's $. Ajax by default.

2. For the entire backbone, only the sync of the model and collection will call backbone. Sync.

3. The request type is determined by the first parameter method, which can be create/update/patch/delete/read. It uses restful requests by default.

4. the requested data is determined by the second parameter model. The URL is the URL of the model by default, and the data is the attributes of the model to be converted to JSON. The default data type is JSON.

5. After a request, the model request event is triggered. If the handler of the event is added.

Execution Process

1 process type, from methodmap
2. initialize options.
3. initialize Params, including type, datatype, and URL.
4 during create/update/patch, the contenttype of Params is application/JSON, and Params. Data must have a value. The value of "model" is converted to "JSON ".
5 emulatejson
6 mimicking HTTP
7. processdata is false for non-GET requests.
8. Rewrite xhr in earlier ie versions during patch
9 trigger a request event

 

Diagram

Related:
Http://www.ruanyifeng.com/blog/2011/09/restful.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.