6
我正在使用jquery mobile,並且需要防止特定元素上的滑動事件。這樣做的需要是因爲我正在使用滑塊,我不希望刷新事件被調用。我希望在用戶使用滑塊進行操作時阻止它。我無法找到任何解決方案,所以我在這裏尋求幫助。防止特定元素上的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");
}
}
});
});
謝謝。
那麼在我的情況下,這樣可以防止滑塊移動但不是p年齡過渡...是否有可能通過.on('swipe',':not(.ui-slider)',transition)來實現? – IazertyuiopI
@Iazertyuiop我當然可以使用':not()'選擇器。 – Omar
例如,selector ='「swipeleft」,「.foo:not(.ui-slider)」,function'。 @IazertyuiopI – Omar