2013-07-31 94 views
0

我使用jQuery Mobile的用于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文件中。

我用这个代码(计算器上找到) - 没有想贴在旧线。

$(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"); 
} 

请告诉我为什么我需要重新加载页面此JavaScript来由于您使用的$(document)工作

回答

0

。就绪

那是一个JQuery的事件。因为网页是由使用AJAX,这意味着该事件不会触发JQM加载

jQuery Mobile的都有自己的加载事件。

我想你可能想要做的是在pageinit但检查文档,看看是否有爱茉莉您的具体情况适当的事件。

JQuery Mobile documentation

+0

欢呼声回复。 – user2630769

+0

还在试图解决如何在这里发布!我尝试了pageinit和pagechange事件,但仍然没有运气。在做这些评论时,你如何得到一个新的线,我继续按下输入并提交 – user2630769