2:cc1e5f212e6c
Anton Shestakov <engored@ya.ru>, Tue, 25 Dec 2012 17:09:32 +0900
Since CodernityDB 0.4.0 get_many is not limited to 1 item by default, so omit limit=-1.

next change 11:84505e73e061
previous change 0:a02e94c5b96b

static/js/framework/views/base.js

Permissions: -rw-r--r--

Other formats: Feeds:
var CollectionView = Backbone.View.extend({
appendItem: function() {},
updateItem: function() {},
removeItem: function() {},
clear: function() {},
repopulate: function() {
this.clear();
this.collection.each(this.appendItem, this);
},
bindCollection: function() {
this.repopulate();
this.collection
.on('add', this.appendItem, this)
.on('change', this.updateItem, this)
.on('remove', this.removeItem, this)
.on('reset', this.repopulate, this);
},
unbindCollection: function() {
this.collection.off(null, null, this);
},
compileTemplates: function(templates) {
this.templates = {};
_.each(templates, function(template, name) {
this.templates[name] = _.template(template);
}, this);
}
});
var CollectionCounterView = CollectionView.extend({
initialize: function(options) {
this.bindCollection();
},
appendItem: function() {
this.repopulate();
},
removeItem: function() {
this.repopulate();
},
repopulate: function() {
this.$el.html(this.collection.models.length);
}
});