Home » Backbone.js new model()

Backbone.js new model()

by Online Tutorials Library

Backbone.js Model Constructor / Initialize

The Backbone.js initialize function is invoked by a class constructor while a model instance is created.

When model instance is created, the class’s constructor gets called.

Syntax:

Parameter explanation:

attributes: Attributes define properties of a model, when creating instance of that model.

options: These are the options such as id, name etc used with attributes when model is created.

Let’s take an example.

See this example:

You may also like