Skip to content

Instantly share code, notes, and snippets.

@tripitakit
Created November 13, 2013 13:30
Show Gist options
  • Save tripitakit/7449120 to your computer and use it in GitHub Desktop.
Save tripitakit/7449120 to your computer and use it in GitHub Desktop.
A test with two commonJS modules in Titanium
var win = Titanium.UI.createWindow({
backgroundColor:'#fff',
layout:"vertical"
});
win.open();
var module = require('myModule');
module.createScanPage(win);
var myResultTxt;
exports.createScanPage = function(theWindow) {
myResultTxt = Ti.UI.createLabel({
text: 'Some initial text',
top:40,
});
theWindow.add(myResultTxt);
theButton = Ti.UI.createButton({
title: 'Do something',
top:20
});
theButton.addEventListener('click', function() {
alert('clicked');
var b = require('myModule2');
b.startScanning();
});
theWindow.add(theButton);
};
exports.setResultText = function(str) {
myResultTxt.text = str;
};
exports.startScanning = function() {
var a = require('myModule');
a.setResultText('My new text');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment