Created
June 3, 2013 16:15
-
-
Save phiggins42/5699277 to your computer and use it in GitHub Desktop.
mixin for widget
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
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