Skip to content

Instantly share code, notes, and snippets.

@pec1985
Created April 21, 2011 00:38
Show Gist options
  • Save pec1985/933412 to your computer and use it in GitHub Desktop.
Save pec1985/933412 to your computer and use it in GitHub Desktop.
How to use require() with Titanium
// 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