Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery手机刷卡功能仅在页面刷新后工作_Javascript_Jquery_Html - Fatal编程技术网

Javascript jquery手机刷卡功能仅在页面刷新后工作

Javascript jquery手机刷卡功能仅在页面刷新后工作,javascript,jquery,html,Javascript,Jquery,Html,我在ipad上使用jquery mobile进行侧扫手势 下面的代码在我的html文件中引用的文件中 我的html文件有: <div data-role="page" id="device1"> <!--content for this part of html page --> </div> <!--more divs with incrementing id --> <div data-role="page" id="device4"&g

我在ipad上使用jquery mobile进行侧扫手势

下面的代码在我的html文件中引用的文件中

我的html文件有:

<div data-role="page" id="device1">
<!--content for this part of html page -->
</div>
<!--more divs with incrementing id -->
<div data-role="page" id="device4">
<!--content for this part of html page -->
</div>

此格式用于多个html文件

我使用此代码(在stackoverflow上找到)-我不想在旧线程上发布

    $(document).ready(function() {

    $('.ui-slider-handle').on('touchstart', function(){
        // When user touches the slider handle, temporarily unbind the page turn handlers
        doUnbind();
    });

    $('.ui-slider-handle').on('mousedown', function(){
        // When user touches the slider handle, temporarily unbind the page turn handlers
        doUnbind();
    });

    $('.ui-slider-handle').on('touchend', function(){
        //When the user let's go of the handle, rebind the controls for page turn
        // Put in a slight delay so that the rebind does not happen until after the swipe has been triggered
        setTimeout( function() {doBind();}, 100 );
    });

    $('.ui-slider-handle').on('mouseup', function(){
        //When the user let's go of the handle, rebind the controls for page turn
        // Put in a slight delay so that the rebind does not happen until after the swipe has been triggered
        setTimeout( function() {doBind();}, 100 );
    });

    // Set the initial window (assuming it will always be #1
    window.now = 1;

    //get an Array of all of the pages and count
    windowMax = $('div[data-role="page"]').length; 

   doBind();
});


// Functions for binding swipe events to named handlers
function doBind() {
    $('div[data-role="page"]').on("swipeleft", turnPage); 
    $('div[data-role="page"]').on("swiperight", turnPageBack);
}

function doUnbind() {
    $('div[data-role="page"]').die("swipeleft", turnPage);
    $('div[data-role="page"]').die("swiperight", turnPageBack);
}

// Named handlers for binding page turn controls
function turnPage(){
    // Check to see if we are already at the highest numbers page            
    if (window.now < windowMax) {
        window.now++
        $.mobile.changePage("#device"+window.now, "slide", false, true);
    }
}

function turnPageBack(){
    // Check to see if we are already at the lowest numbered page
    if (window.now != 1) {
        window.now--;
        $.mobile.changePage("#device"+window.now, "slide", true, true);
    }
}

// Named handlers for binding page turn controls
function navigate_without_swipe(page){
    // Check to see if we are already at the highest numbers page            
    $.mobile.changePage("#device"+page, "slide");
}
$(文档).ready(函数(){
$('.ui滑块句柄')。在('touchstart',function()上{
//当用户触摸滑块控制柄时,暂时解除翻页处理程序的绑定
doUnbind();
});
$('.ui滑块句柄').on('mousedown',function()){
//当用户触摸滑块控制柄时,暂时解除翻页处理程序的绑定
doUnbind();
});
$('.ui滑块句柄')。在('touchend',function()上{
//当用户松开手柄时,重新绑定翻页控件
//稍微延迟一下,以便在刷卡触发之前不会重新绑定
setTimeout(函数(){doBind();},100);
});
$('.ui滑块句柄').on('mouseup',function(){
//当用户松开手柄时,重新绑定翻页控件
//稍微延迟一下,以便在刷卡触发之前不会重新绑定
setTimeout(函数(){doBind();},100);
});
//设置初始窗口(假设它始终为#1
window.now=1;
//获取所有页面的数组并计数
windowMax=$('div[data role=“page”])。长度;
doBind();
});
//用于将滑动事件绑定到命名处理程序的函数
函数doBind(){
$('div[data role=“page”])。打开(“swipeleft”,翻页);
$('div[data role=“page”])。打开(“swiperight”,翻页);
}
函数doUnbind(){
$('div[data role=“page”]).die(“swipeleft”,翻页);
$('div[data role=“page”]).die(“swiperight”,翻页);
}
//用于绑定翻页控件的命名处理程序
函数翻页(){
//查看我们是否已经在最高数字页面
如果(window.now
请告诉我为什么我需要重新加载此javascript才能工作,因为您正在使用$(document)。准备好了吗

这是一个JQuery事件

jquerymobile有自己的加载事件,因为页面是由JQM使用AJAX加载的,这意味着不会触发该事件

我认为您可能希望在一个特定的时间内这样做,但请检查文档,看看是否有更适合您的情况的事件


仍在尝试如何在此处发布!我尝试了pageinit和pagechange事件,但仍然没有成功。顺便说一句,在执行其中一条评论时,您如何获得新行?我一直按enter键,它会提交