emvece
v1.0.41
Published
a very simple mvc scaffold
Downloads
22
Readme
emvece
a very simple mvc scaffold.
- Model
- Collection
- View
loosely inspired by backbone.
uses onlooker for observer implementation
// model
var link = emvece.Model.subclass({
defaults: {
title: '',
url: '',
},
});
// view
var view = emvece.View.subclass({
tagName: 'div',
elementClasses: ['link-view'],
elementAttributes: {
id: 'link-view',
},
render: function() {
addToDom(this.element, this.model.getAttributes());
},
init: function() {
var self = this;
// observer
this.model.on('changed:title changed:url', function(value, old) {
self.render();
});
}
});
var model = new link({ title: 'github', url: 'https://github.com' });
var page = new view({model:model});
page.render()
model.set({ title: 'Github' });