Created
November 13, 2013 13:30
-
-
Save tripitakit/7449120 to your computer and use it in GitHub Desktop.
A test with two commonJS modules in Titanium
This file contains hidden or 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
| var win = Titanium.UI.createWindow({ | |
| backgroundColor:'#fff', | |
| layout:"vertical" | |
| }); | |
| win.open(); | |
| var module = require('myModule'); | |
| module.createScanPage(win); |
This file contains hidden or 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
| 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; | |
| }; |
This file contains hidden or 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
| 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