开发者

Appcelator Titanium : Calling a function of parentWindow from childWindow?

开发者 https://www.devze.com 2023-02-26 17:25 出处:网络
Win1.js var Appwin = Titanium.UI.createWindow(); function checkPage() { } Appwin.open开发者_StackOverflow();
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
    });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消