我已经实现了一个透明的弹出对话框,它必须允许用户通过用户触摸向右或向左滑动。问题是当我向左或向右滑动时,它不是关闭最后一个对话框,而是创建一个新对话框,因此通过按关闭按钮它会显示所有其他重复对话框。似乎当我向右或向左擦拭时,它会创建一个新对话框而不是显示现有对话框。还有如何在其他滑动对话框中保持父对话框的透明度。
这是带有完整代码的小提琴http://jsfiddle.net/EacrU/1/
下面是我用于滑动的 js 代码
$( document ).on( "pageinit", "[data-role='dialog'].background-change", function() {
var page = "#" + $( this ).attr( "id" );
// Check if we did set the data-next attribute
if ( page=='#background-changer-1' )
{
try{
// Prefetch the next page
$.mobile.loadPage("#background-changer-2" );
}
catch(exception)
{
alert(exception);
}
$( document ).on( "swipeleft", page, function() {
$.mobile.changePage("#background-changer-2", { transition: "slide", reverse: false } );
});
// Navigate to next page when the "next" button is clicked
$( ".control .next", page ).on( "click", function() {
$.mobile.changePage( "#background-changer-2" , { transition: "slide" } );
});
}
if ( page=='#background-changer-2' )
{
try{
// Prefetch the next page
$.mobile.loadPage("#background-changer-1" );
}
catch(exception)
{
alert(exception);
}
$( document ).on( "swiperight", page, function() {
$.mobile.changePage("#background-changer-1", { transition: "slide", reverse: true } );
});
// Navigate to next page when the "next" button is clicked
$( ".control .prev", page ).on( "click", function() {
$.mobile.changePage( "#background-changer-1" , { transition: "slide" } );
});
}
});