Javascript 为什么jquery移动侧面板触摸屏不滑动';如果不在触摸事件上使用event.preventDefault(),则无法顺利工作?
我在触摸时使用event.preventDefault()将事件正确移动到工作面板幻灯片。但它停止了我应用程序中的所有滚动 没有此代码,我无法顺利打开侧面板。(尝试3-4次后打开) 用手指在右侧滑动时打开/关闭面板的代码Javascript 为什么jquery移动侧面板触摸屏不滑动';如果不在触摸事件上使用event.preventDefault(),则无法顺利工作?,javascript,jquery,jquery-mobile,cordova,Javascript,Jquery,Jquery Mobile,Cordova,我在触摸时使用event.preventDefault()将事件正确移动到工作面板幻灯片。但它停止了我应用程序中的所有滚动 没有此代码,我无法顺利打开侧面板。(尝试3-4次后打开) 用手指在右侧滑动时打开/关闭面板的代码 $(document).on('pageinit', function(event){ // Bind the swipeHandler callback function to the swipe event on div.box $( "[dat
$(document).on('pageinit', function(event){
// Bind the swipeHandler callback function to the swipe event on div.box
$( "[data-role='page']" ).on( "swiperight", function( event, ui ) {swipeRightHandler($.mobile.activePage.attr('id'));} );
function swipeRightHandler( page_id ){
$( "#"+page_id+"_panel" ).panel( "open" );
}
});
已经使用过,面对同样的问题,面板在屏幕上滑动3-4次后就会打开。为什么你们认为它会停止所有的滚动?您认为在
文档
级别调用.preventDefault()
触控移动事件所阻止的默认操作是什么。您使用了错误的代码来解决问题。你的问题应该包括你实际面临的问题,而不是你正在使用的一个不会带来很多好处的黑客sense@nnnnnn-是的,它停止了我应用程序中的所有滚动。那么你的问题是什么?如果知道被阻止的默认操作是滚动,为什么要调用preventDefault()
?
$(document).on('pageinit', function(event){
// Bind the swipeHandler callback function to the swipe event on div.box
$( "[data-role='page']" ).on( "swiperight", function( event, ui ) {swipeRightHandler($.mobile.activePage.attr('id'));} );
function swipeRightHandler( page_id ){
$( "#"+page_id+"_panel" ).panel( "open" );
}
});