Created
August 14, 2012 19:07
-
-
Save eastridge/3351794 to your computer and use it in GitHub Desktop.
Thorax bind docs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thorax Bind Plugin | |
================== | |
## View Helpers | |
### bind *{{#bind "methodName"}}* | |
Standalone usage: | |
new Thorax.View({ | |
template: '{{bind "counter"}}', | |
i: 0, | |
counter: function(i) { | |
if (arguments.length === 1) { | |
this.i = i; | |
} | |
return this.i; | |
} | |
}); | |
Fine grain render control with a model: | |
var view = new Thorax.View({ | |
template: '<div>{{bind "key" tag="span"}}</div>' | |
}); | |
var model = new Backbone.Model({ | |
key: 'value' | |
}); | |
view.setModel(model, { | |
render: false, | |
watch: ['key'] | |
}); | |
view.render(); | |
//will not re-render | |
model.set({anotherKey: 'value'}); | |
//will only update the generated span | |
model.set({key: 'new value'}); | |
### bindAttr *{{bindAttr attrName="methodName"}}* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment