I have just started exploring Backbone.js.
Upon submission of a form I would like Backbone.js to save the details to database.
How can I go about this?
Backbone is wonderful because it does a lot of work for you. To save our donut and secondHelping, we simply do this: myDonut. save(); mySecondHelping.
Backbone. Backbone has been around for a long time, but it's still under steady and regular development. It's a good choice if you want a flexible JavaScript framework with a simple model for representing data and getting it into views.
Backend Synchronization BackboneJS is use with the front-end and back-end systems, allows the synchronization with the backend to provide support to RESTful APIs.
Backbone. js is an ideal choice for front-end and back-end development because it supports REST APIs that are used to keep the front-end and back-end in sync.
Unless you are using HTML5 local storage in the client the responsibility for saving to the database is not with backbone.js. Backbone will talk to the server via Backbone.sync using a REST type request. Effectively it will make an http POST request to save a new record or an http PUT request to update a current record.
The difference between a new record and a current record is that the :id field of the record is not set for a new record and is set for an old record.
If you want a tutorial using Ruby Rails as your backend solution then you can look at this tutorial.
http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/
However you can use any backend server such as PHP, Java, Django etc as long as they meet the requirements of the REST interface that backbone.js uses.
If you overide Backbone.sync you can also get backbone.js to interface to pretty much any legacy http protocol as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With