2012-12-18 38 views
1

我是鈦合金的新手,我面臨一個問題。 在我的app.js中,我包括左側菜單和控件到窗口(app.js和leftmenu.js)在按鈕上創建一個新窗口時,UI會凍結點擊

我想在用戶單擊菜單項時加載一個窗口。基本上,我想在用戶選擇主頁按鈕時加載app.js主窗口。 對於這一點,我下面的代碼到leftmenu.js文件:

var newWin = Titanium.UI.createWindow({ 
    url: "app.js", 
    zIndex: 0 
}); 
win.close(); // closing main window 
leftMenu.close(); // closing left menu 
newWin.open(); //should reload the main window and the leftmenu 

它重新加載窗口,但所有控件都禁用。我們無法點擊任何控件。就好像所有的控件都在一個不可見的層次下。 有什麼想法?

我複製/粘貼代碼部分,也許這將是更清晰:)

btnaccueil.addEventListener('click',function(e) { 
    var newWin = Titanium.UI.createWindow({   
     url: "app.js", 
     zIndex: 0 
    }); 

    // Closing current instance for freeing memory 
    win.close(); 
    leftMenu.close(); 
    newWin.open({animated:true}); 
    Ti.API.info(var_dump(newWin)); 
}); 

回答

0

你好,我知道了,一個月後,但你需要使用的出口/ module.exports?這裏是如何打開一個按鈕事件的正確方法一個新的窗口,我想使用url屬性已被棄用的例子,所以我希望這個例子可以幫助你理解

employee.js

//Current window (employee window) 
var employeeWin = Ti.UI.currentWindow; 

//define button 
var moveToDetailBtn = Ti.UI.createButton({ 
    width  : 200,  //define the width of button 
    height  : 50,  //define height of the button 
    title   : 'Show Detail' //Define the text on button 
}); 

//Click event to open the Employee Details window 
moveToDetailBtn.addEventListener('click', function(){ 

    //Call a export function 
    var win = require('employeeDetails').getEmployeeDetailSWin; 

    //Create new instance 
    var employeeDetailsWin = new win(); 

    //Open the Employee Details window 
    employeeDetailsWin.open(); 
}); 

//Add the button to the window 
employeeWin.add(moveToDetailBtn); 

在employeeDetails.js

exports.getEmployeeDetailSWin = function(){ 

    //Creates a new window 
    var empDetailsWin = Ti.UI.createWindow({ 
     backgroundColor : '#ffffff'  //Define the backgroundcolor of the window 
    }); 

    //Addin a label to the window 
    empDetailsWin.add(Ti.UI.createLabel({ 
     width  : 100,  //Define width of the label 
     height  : 50,  //Define height of the label 
     title   : 'Employee Details' 
    })); 

    return empDetailsWin; 
}; 

除了我不知道,如果你可以導出app.js嘗試使用新的.js

相關問題