通过结合加载外部文件打开弹出窗口,我遇到了麻烦。前两次效果很好。第三次出现“找不到文件”错误,即使该文件可用。(这是一个移动网络应用程序,我在 Safari / jQueryMobile 上试用它)。
这是我的代码:
$(document).on("pageinit", '#pageContainer', function() {
$.mobile.allowCrossDomainPages = true;
$("a", "#list").click(function (event, ui) {
var attr = $(this).attr('id');
var name = attr.replace ('linkID','');
$("#singleSwipe_popup").load('dynamic/' + name + '.html', function() {
$(".singlePopup" ).on({
popupbeforeposition: function() {
// init Swipe-Slider ... on global var singleSwipeSlider ... Works ...
}, popupafterclose: function() {
delete singleSwipeSlider; // destroy the swipe slider
$('#singleSwipe_popup').empty(); // clean popup content
}
});
});
});
});
HTML:
<div id="prodPopupsConainter">
<div data-role="popup" class="singlePopup ui-corner-none" id="popupSingle" data-overlay-theme="b">
<a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-left">Close</a>
<div id="singleswipe-left" class="swipe-left"></div>
<div class="wrapAndFloat" id="singleSwipe_popup">
<!-- POPUP content comes here -->
</div>
<div id="singleswipe-right" class="swipe-right"></div>
</div>
</div>
.... 如果没有弹出窗口的 html 代码和“ $("#prodPopupsConainter").load ...
”,动态加载效果很好。
谁能给我一个解决方案?