Created
August 5, 2010 10:14
-
-
Save osmeest/509513 to your computer and use it in GitHub Desktop.
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
var common = { value: "123", title: "None" }; | |
var tabGroup = Titanium.UI.createTabGroup(); | |
for(var i = 0; i < 2; ++i) { | |
var win = Titanium.UI.createWindow({ | |
title : "Test #" + i, | |
backgroundColor: '#fff', | |
url: "tab.js" | |
}); | |
win.common = common; | |
var tab = Titanium.UI.createTab({ | |
title: "Test " + i, | |
window: win | |
}); | |
tabGroup.addTab(tab); | |
} | |
tabGroup.open(); |
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
var win = Titanium.UI.currentWindow, | |
common = win.common; | |
var field; | |
field = Titanium.UI.createTextField( { | |
value : "", | |
width : 90, height : 30, left: 10, top: 10, | |
borderStyle : Titanium.UI.INPUT_BORDERSTYLE_ROUNDED | |
}); | |
win.add(field); | |
win.addEventListener('focus', function(e) { | |
Ti.API.info('focus updating value: value=' + common.value + " title=" + common.title); | |
field.value = common.value; | |
common.title = win.title; | |
Ti.API.info('Now, value=' + common.value + " title=" + common.title); | |
}); | |
win.addEventListener('blur', function(e) { | |
Ti.API.info('blur check: field=' + field.value + ' value=' + common.value + " title=" + common.title); | |
}); | |
field.addEventListener('change', function(e) { | |
Ti.API.info('field changed value to ' + e.value); | |
common.value = e.value; | |
Ti.API.info('After update, value=' + common.value + " title=" + common.title); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does not seem to work... Seems the common object is passed by value, not by reference as can be seen in the debug log: