我正在尝试在更改后从价格滑块中检索价值。
价格滑块:
<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])
但它不起作用 - 如何从价格滑块中获取当前值?
答案 0 :(得分:0)
你试过了吗? $(“#amount”)。slider(“value”) 代替 $( “#量”)。VAL(ui.values [0])
http://jqueryui.com/slider/#rangemin
确保在jquery网站上显示源代码。
或者,如果您尝试在filterBy()函数中调用它,请确保将ui作为参数传递?
只是一个猜测......