0
我試圖從更改後的價格滑塊中檢索值。jQuery在價格滑塊更改後獲取值
價格滑塊:
<script>
$(function() {
$("#slider-range").slider({
range: true,
min: 0,
max: 5000,
values: [ 500, 2000 ],
slide: function(event, ui) {
$("#amount").val(ui.values[ 0 ] + " kr" + " - " + ui.values[ 1 ] + " kr");
},
change: function(event, ui) {
filterBy(ui);
}
});
$("#amount").val($("#slider-range").slider("values", 0) + " kr" +
" - " + $("#slider-range").slider("values", 1) + " kr");
});
</script>
filterBy(UI)
<script>
function filterBy(ui) {
$('.searchtable').addClass('hide');
$('.spinner').removeClass('hide');
$.ajax({
type: 'GET',
data: {'name':'<?php echo strval($_GET['name']); ?>','arrival':'<?php echo strval($_GET['arrival']); ?>','departure':'<?php echo strval($_GET['departure']);?>','guests':'<?php echo strval($_GET['guests']);?>','minRate':$("#amount").val(ui.values[0]),'propertyCategory':$("#hotelType input[type='checkbox']:checked").val(),'minStarRating':$("#hotelRating input[type='checkbox']:checked").val()},
url: '<?php echo $baseUrl ?>/hotels/hotelFilterResult.php',
success: function (data) {
alert('data loaded succesfully');
alert(this.url);
$('.searchtable').replaceWith(data);
$('.spinner').addClass('hide');
$('.searchtable').removeClass('hide');
},
error: function (xhr) {
alert('data not loaded');
}
});
}
</script>
試圖讓在第一位置的價格滑塊的電流值(0)。這個數據元素:
$.ajax({
type: 'GET',
data: {'name':'<?php echo strval($_GET['name']); ?>','arrival':'<?php echo strval($_GET['arrival']); ?>','departure':'<?php echo strval($_GET['departure']);?>','guests':'<?php echo strval($_GET['guests']);?>','minRate':$("#amount").val(ui.values[0]),'propertyCategory':$("#hotelType input[type='checkbox']:checked").val(),'minStarRating':$("#hotelRating input[type='checkbox']:checked").val(),'amenities':$("#hotelAmenities input[type='checkbox']:checked").val()},
url: '<?php echo $baseUrl ?>/hotels/hotelFilterResult.php',
試圖通過這種檢索它:
'minRate':$("#amount").val(ui.values[0])
但doesen't工作 - 我如何才能在這裏的價格滑塊的當前值?
是我嘗試在filterBy()中調用 - 如何傳遞ui參數? – 2015-02-23 17:08:11
啊我看你使用範圍滑塊,所以調用(「值」)是好的。至於filterBy我會嘗試:在你的更改事件處理程序中:filterBy(ui)並且不要忘記你的函數定義函數filterBy(ui) – vm2013 2015-02-23 17:11:13
中的參數,所以說filterBy(ui)應該傳遞參數? @ vm2013 – 2015-02-23 17:17:19