Created
July 31, 2012 19:08
-
-
Save rblalock/3219595 to your computer and use it in GitHub Desktop.
Require
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
// Require works differently as you are bringing in methods and other things attached | |
// to it's own controller: | |
// index.xml | |
<Window id="win1"> | |
<Require src="myThing" id="myThing" /> | |
</Window> | |
// index.js controller | |
$.win1 | |
$.myThing.loginButton | |
$.myThing.toggleScreen(); | |
// myThing view: | |
<View id="mySnippet"> | |
<Label /> | |
<Button id="loginButton" /> | |
</View> | |
// myThing controller | |
// normal access: | |
$.loginButton | |
$.mySnippet | |
// custom methods etc: | |
$.toggleScreen = function() {}; | |
$.isSelected = false; | |
// This way you can also do things like have difference instances: | |
<Window id="win1"> | |
<Require src="myThing" id="myThing" /> | |
<Require src="myThing" id="anotherThing" /> | |
<Require src="myThing" id="andAnotherThing" /> | |
<Require src="myThing" id="thing" /> | |
</Window> | |
// Accessed: | |
$.myThing.toggleScreen(); | |
$.anotherThing.toggleScreen(); | |
$.andAnotherThing.toggleScreen(); | |
$.thing.toggleScreen(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment