Skip to content

Instantly share code, notes, and snippets.

@phiggins42
Created June 3, 2013 16:15
Show Gist options
  • Save phiggins42/5699277 to your computer and use it in GitHub Desktop.
Save phiggins42/5699277 to your computer and use it in GitHub Desktop.
mixin for widget
function attachpoint(selector){
return function(){
return this.$(selector);
}
}
// eg:
declare(WidgetBase, {
$: function(selector){
return query(selector, this.domNode);
},
myThing: attachpoint("ul.thinger"),
postCreate: function(){
console.log(this.myThing());
}
})
var MyView = View.extend({
myThing: attachpoint("ul.thinger"),
clicker: function(e){
this.myThing().append("<li>Hi</li>");
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment