Making a new backbone Model with Backbone.Model.extend
In order to get started making a backbone model the first thing to do is use Backbone.Model.extend, and give it an object that will contain all of the methods, and objects that will be used to define the Model.
What to know before hand
In this post I am writing about the Main method that is used to make in instance of a backbone model. This is not a post for anyone that is new to backbone, let alone javaScript. If that is the case I have a getting started post for backbone that will help get you up to speed.
Be sure to also check out my post on backbone Models in general as well.
A quick Backbone.Model.extend example
The Backbone.Model.extend method is where all the magic happens when making a Model with backbone. All I have to do is pass the Method an object that contains all of the methods, and attributes that compose a constructor that ca be used to make one or more instances of that Model.
For a quick, simple example I will throw together a Model that is the beginning of what might become an Idle game. Because making an idle game is way more fun than yet another todo app.
|
|