Kristian
Kristian

Reputation: 21840

backbone.js model extends another model

I'm building a dashboard application with Backbone.js

There is a grid of panes called modules. Each module has its own custom data that it needs to listen to.

In this sense, I have created a backbone model called Module that is basically the top-level information for each module like module_name & module_description

my first inclination is to find a way to make a new special module model per module... like a "counter" module, a "messages" module, etc.

how should I approach the separate & different data per module? any design pattern recommendations?

Upvotes: 4

Views: 1605

Answers (1)

Captain Obvious
Captain Obvious

Reputation: 785

You can do something like this:

var Module = Backbone.Model.extend({
// default properties/methods of this module
});

var MessageModule = Module.extend({
// new properties/methods of this module
});

Upvotes: 7

Related Questions