Open cybernetlab opened 9 years ago
Why so complex, why not just:
// in common ancestor
// override if needed
bindings: function () {
var bindings = {};
if (this.model) {
bindings.model = model;
}
if (this.collection) {
bindings.collection = this.collection;
}
return bindings;
}
// somewhere in onRender
Rivets.bind(this.el, _.result(this, 'bindings'));
@hogart because I want to keep data bindings in code (not in templates)
Hi! I adopting rivets to use it with Backbone and Marionette. And I want to provide a way to make bindings from code in class declarations like this:
that would be equivalent to following markup:
After some digging in your code I've wrote binding function for this purpose (with some simplification) that is called from Marionette
onRender
event:And now I have two questions:
buildBinding
in right way?bindings.sort
and other post-binding stuff to separate function with name likeupdateBindings
. Then users will be able to call it after such custom binding?Thanks!