Adding an event listener to a proxy that isn't already in the context。
用 navGroup打開一個window,然後新建leftnavbutton,並註冊事件,會報錯:
Adding an event listener to a proxy that isn't already in the context。
一步步刪代碼,發現是事件註冊問題。。
網上資料:http://developer.appcelerator.com/question/135176/error-adding-an-event-listener-to-a-proxy-that-isnt-already-in-the-context#answer-237243
“A quick and dirty fix for this issue is to set the backgroundGradient AFTER you have created the button and added it to a view. This will put the button into the context and prevent this message from displaying.”
我覺得這句話有點道理,所以我加了settimeout來延時註冊 button的事件,有一定效果額~
不知道這麼做會有什麼後遺症。。。 8)
setTimeout(function() {
leftButton.addEventListener("click", function() {
currentWindow.fireEvent("closeWindow");
});
}, 50);