Created
April 21, 2011 00:38
-
-
Save pec1985/933412 to your computer and use it in GitHub Desktop.
How to use require() with Titanium
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
// this would be app.js (for example) | |
var UI = require('myfile'); // no .js extension | |
var win = UI.Window({backgroundColor:'#999'}); | |
var view = UI.View({top:20,left:20,right:20,bottom:20,backgroundColor:'#ccc'}); | |
win.add(view); | |
win.open(); | |
//========================================================== | |
// this would be myfile.js | |
exports.Window = function(e){ | |
return Ti.UI.createWindow(e); | |
}; | |
exports.View = function(e){ | |
return Ti.UI.createView(e); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment