外部ファイルの読み込みと組み合わせてポップアップを開くと問題が発生します。最初の2回はうまくいきます。3 回目には、ファイルが利用可能であっても「ファイルが見つかりません」というエラーが表示されます。(これはモバイル WebApp であり、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 ...
" がなければ、動的な読み込みはうまく機能します。
誰でも私に解決策を教えてもらえますか?