Skip to content

Instantly share code, notes, and snippets.

@rblalock
Created July 31, 2012 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rblalock/3219595 to your computer and use it in GitHub Desktop.
Save rblalock/3219595 to your computer and use it in GitHub Desktop.
Require
// 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