开发者

how to navigate or call ant .js file in titanium

hey all, how to navigate/call other .js file after click event on button. once i开发者_运维百科t ciick it will goes to other window. osplease help me to solve this problem

thanks,


Please find below a quick sample, focused around iOS. There are a bunch more available in the Kitchen Sink example App available here: https://github.com/appcelerator/titanium_mobile/tree/master/demos/KitchenSink

Steps:

1) Create Titanium Mobile Project

2) In the app.js file add the below

var winPage1 = Ti.UI.createWindow({
    url:'page1.js', title:'Page 1'
});

winPage1.open();

3) Add a file in the same directory as app.js called page1.js, then paste this in


var win = Ti.UI.currentWindow;

(function(){
    var b1 = Ti.UI.createButton({
        title : 'Press Me',
        left : 10, top : 100, right : 10, height : 40
    });
    b1.addEventListener('click', function(e) {
        var wPage = Ti.UI.createWindow({ 
                title:'Test Page2',
                backgroundColor:'yellow',
                url:'page2.js'
        });

        wPage.open({modal:false});
    });

    win.add(b1);

})();

4) Add a file in the same directory as app.js called page2.js, then paste this in

var win = Ti.UI.currentWindow;

(function(){
    var b1 = Ti.UI.createButton({
        title : 'Press Me',
        left : 10, top : 100, right : 10, height : 40
    });
    b1.addEventListener('click', function(e) {
        win.close();
    });

    win.add(b1);

})();

5) Run in Titanium Developer or Studio

This should give you a running same showing how to open and close windows. Kitchen Sink (link above) has a ton more samples showing different ways to do this.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜