February 2019
Beginner
694 pages
18h 4m
English
From the Backbone documentation, we find an example of creating a Backbone.Model class in JavaScript, as follows:
var NoteModel = Backbone.Model.extend ({ initialize: function() { console.log("NoteModel initialized."); }, author: function() {}, coordinates : function() {}, allowedToEdit: function(account) { return true; }});
This code shows typical usage of Backbone in JavaScript. We start by creating a variable named NoteModel that extends (or derives from) Backbone.Model. This can be seen with the Backbone.Model.extend syntax. The Backbone extend function uses JavaScript object notation to define an object within the outer curly braces { ... }. In this example, the NoteModel object has four functions:
Read now
Unlock full access