0
當我嘗試打開一個對話框時,它從它打開的頁面重新加載JavaScript文件。 頁面不刷新,它只是JavaScript。jQuery Mobile對話框從它被打開的頁面重新加載JavaScript從
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<link rel="stylesheet" href="css/frameworks/jquery.mobile-1.3.0.css">
<script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery.mobile-1.3.0.js"></script>
<script src="js/test.js"></script>
</head>
<body>
<div id="page" data-role="page">
<a href="dialog.html" data-rel="dialog" transition="pop" data-role="button" data-icon="check" data-inline="true">Open Dialog</a>
</div>
</body>
</html>
dialog.html只是默認頁面,test.js包含:
$(document).bind('pageinit', function() {
alert("fire");
}
如何預防呢?
我實現你的代碼,但結果是一樣的:顯示test.js的警報打開對話框時。 難道它不得不用$ .mobile.ajaxEnabled做些什麼嗎? – joekeee 2013-04-26 11:31:03
@joekeee它應該被啓用,因爲它通過Ajax加載對話框。 – Omar 2013-04-26 12:11:25