我正在開發一個在cordova + onsenui上的移動應用程序。我基本上有一個通用的template.html,我第一次加載,然後通過jquery修改所需的具體參數。我第一次執行一個Ajax請求以獲取該模板的細節,然後我用onsenui:「pushPage已在運行」和「無法讀取屬性'removeEventListener'null」
fn.pushPage({'id': 'template.html', 'title': 'View template'});
加載模板和更改與jQuery所需要的所有參數。起初,應用程序將嘗試執行更改之前的模板將加載完成,該文檔準備事件是行不通的,所以我在的jQuery的onSuccess部分做了一個通用的功能,像這樣的
function update_template(){
if ($('#templateItem').length) {
//this part runs if the template has loaded
//replace all the poarameters with jquery
} else {
window.setTimeout(edit_profile, 0.1); // 5 seconds
}
};
這似乎工作確定,但要到前一頁與運行
的document.getElementById(「appNavigator」)後退按鈕後。popPage()
我在控制檯中的錯誤信息說
Uncaught (in promise) TypeError: Cannot read property 'removeEventListener' of null
,如果我嘗試再次看到了模板,我得到
Uncaught (in promise) pushPage is already running.
如果我刪除修改模板代碼的一部分,一切正常,沒有問題回去,沒有錯誤消息並沒有什麼問題再次加載模板。