Skip to content

Commit

Permalink
From custom code to underscore supported on Backbone 1.0
Browse files Browse the repository at this point in the history
Signed-off-by: José Luis Di Biase <josx@interorganic.com.ar>
  • Loading branch information
josx committed May 21, 2013
1 parent 7789a19 commit f532115
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions public/js/views/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ window.ConfView = Backbone.View.extend({
el: $("#content"),
initialize: function () {
this.render();
this.configModel = this.filter('type', 'config');
this.defaultModel = this.filter('type','defaults');
this.configModel = this.collection.findWhere({ type: 'config' });
this.defaultModel = this.collection.findWhere({ type: 'defaults' });
},
render: function () {
$(this.el).html(template.confview({ config: this.collection.toJSON() }));
Expand Down Expand Up @@ -60,12 +60,5 @@ window.ConfView = Backbone.View.extend({
$('input#'+selector, this.el).val(default_model[res[0]][res[1]][res[2]]);
}
return false;
},

/* XXX FIXME Newer Backbone versions (>1.0) bind underscore to use it against collections*/
filter: function(prop, value) { return this.collection.find( function(item) {
if (item.get(prop) == value)
return true;
})
},
}
});

0 comments on commit f532115

Please sign in to comment.