« Back
Sammy.Application helper ( name, method )
Helper extends the event context just like helpers() but does it
a single method at a time. This is especially useful for dynamically named
helpers
Example
// Trivial example that adds 3 helper methods to the context dynamically
var app = $.sammy(function(app) {
$.each([1,2,3], function(i, num) {
app.helper('helper' + num, function() {
this.log("I'm helper number " + num);
});
});
this.get('#/', function() {
this.helper2(); //=> I'm helper number 2
});
});
Arguments
nameThe name of the methodmethodThe function to be added to the prototype atname
comments powered by Disqus