What does $ tag mean in Appcelerator? When I use this tag in any controller.js it works. But when I use it in libs js file I get error.
$.resetClass(someController, 'someClass')
$ tag is the holder for a controller file. It is autogenerated by Titanium for every controller file.
Let's say you have these sets of files : 1 - index.xml, index.js, index.tss 2 - win.xml, win.js, win.tss 3 - dialog.xml, dialog.js, dialog.tss
So, $ is available for every .js file & it is the same thing which is returned by this:
dialog.js
var dollar = Alloy.createController('win');
// now dollar is exactly equal to ($ in win.js) & so does for other .js files.
In win.xml, suppose you have a topmost Window or View with an id='topView' & some internal child views lets say having ids = view1, view2, etc...
win.xml
<Alloy>
<View id='topView'>
<View id='view1'>
<View id='view2'></View>
</View>
</View>
</Alloy>
now in win.js file, you can access these view ids like $.topView, $.view1, $.view2 & so on like this...
var topView = dollar.topView;
var view1 = dollar.view1;
var view2 = dollar.view2;
To elaborate more, suppose you want to export some functionality from a controller to any other controller, you can do it this way:
win.js
$.methodNameToAccess = function () {alert('Kerberos!')};
here is the magic of exporting methods
dialog.js
dollar.methodNameToAccess(); // alerts your name :)
This was the basic guide what $ is and it's beyond that.. so it's your task now to explore it & use it efficiently.
Code Strong!