【发布时间】:2013-03-30 20:52:29
【问题描述】:
我正在使用 jquery mobile,我需要防止在特定元素上滑动事件。需要这样做是因为我正在使用滑块,并且我不希望调用滑动事件。我希望在用户使用滑块进行操作时阻止它。我也找不到任何解决方案,所以我在这里寻求帮助。
这是我的 javascript 代码:
$( document ).on( "pageinit", "#demo-page", function() {
$( document ).on( "swipeleft swiperight", "#demo-page", function( e ) {
// We check if there is no open panel on the page because otherwise
// a swipe to close the left panel would also open the right panel (and v.v.).
// We do this by checking the data that the framework stores on the page element (panel: open).
if ( $.mobile.activePage.jqmData( "panel" ) !== "open" ) {
if ( e.type === "swipeleft" ) {
$( "#right-panel" ).panel( "open" );
} else if ( e.type === "swiperight" ) {
$( "#left-panel" ).panel( "open" );
}
}
});
});
谢谢。
【问题讨论】:
标签: jquery-mobile jquery swipe preventdefault