我试图通过更改jquery移动范围最小/最大滑块的用户交互来通过ajax加载一些数据。
<label for="filter_price">Preis:</label>
<div data-role="rangeslider" id="filter_price" style="touch-action: none;">
<input type="range" name="price_from" id="price_from" min="1" max="2000" value="1" data-popup-enabled="true" class="filter_watch">
<input type="range" name="price_to" id="price_to" min="1" max="20000" value="20000" data-popup-enabled="true" class="filter_watch">
</div>
JS:
$('#price_from').on("change mousemove", function
() {
alert('price filter');
})
https://jsfiddle.net/28avj4x5/
在jsfiddle上,每次鼠标移动都会触发警报,而只有触发更改。在我的项目中,事件根本不会发生。我也试过没有任何效果的qazxsw pmi。
如何在更改值并释放按钮时触发事件(ajax调用仅在用户停止交互时触发)?
change.(function...
事件twas专门为此目的设计:
slidestop
在我的代码片段中尝试一下:$(document).on("slidecreate", "#price_from", function(e) {
$(this).on("slidestop", function() {
var val = $(this).val();
// pass val to the ajax call
});
});