Appcelator Titanium : Calling a function of parentWindow from childWindow?
Win1.js
var Appwin = Titanium.UI.createWindow();
function checkPage() {
}
Appwin.open开发者_StackOverflow();
Win2.js
var childWindow = Titanium.UI.currentWindow();
From here how i can call checkPage function
childWindow.open();
The easiest way to do it for your setup is to include it on both files.
Ti.include('functions_files.js');
The other way you could do it is to define both windows in one file with the function and have the windows set to a url.
App.js
var Appwin = Ti.UI.createWindow({
url: 'path/to/Win1.js'
});
var childWindow = Ti.UI.createWindow({
url: 'path/to/Win2.js'
});
function checkPage() {
}
Appwin.open();
childWindow.addEventListener('open', function() {
checkPage();
});
As requested:
Win1.js
var Appwin = Ti.UI.createWindow({
});
Ti.App.addEventListener('checkPage', function(e) {
var tableView = e.tableView;
});
Appwin.open();
Win2.js
var childWindow = Ti.UI.createWindow({
});
var tv = tableView;
childWindow.addEventListener('close', function() {
Ti.App.fireEvent('checkPage', {
tableView = tv
});
});
精彩评论