Actually I'm doing filtering option with pagination.And in that I use checkbox and price slider for performing filters.
I wrote code for the checkbox option as when pagination links were clicked it must checked which checkboxes were clicked..
And coding is here,
<?php
if(isset($_REQUEST['key'])){
$key_val = $_REQUEST['key'];
if(in_array($amn->ht_amenity_id, $key_val)){
?>
<label>
<input class="i-check iCheck-helper" name="{{$keys[$i]}}" type="checkbox" value="{{$amn->ht_amenity_id}}" checked="checked" />{{$amn->ht_amenity_name}}
<?php
echo "<br/><br/>";
}
else{
?>
<label>
<input class="i-check iCheck-helper" name="{{$keys[$i]}}" type="checkbox" value="{{$amn->ht_amenity_id}}" />{{$amn->ht_amenity_name}}
<?php
echo "<br/><br/>";
}}
?>
It works for me..
Here is My code for price slider,
<li>
<h5 class="booking-filters-title">Price</h5>
<?php
if(isset($_REQUEST['from']) && isset($_REQUEST['to'])){
$from = $_REQUEST['from'];
$to = $_REQUEST['to'];
echo $from;exit;
?>
<input type="text" id="price-slider" value="$from;$to">
<?php
}
else{
?>
<input type="text" id="price-slider">
<?php
}
?>
</li>
I tried like this way..But it didn't work for me..
When my pagination links were clicks it pass all the values through the URL.And also the results were given as per my filters.
But the price slider does not change after my pagination links were clicked..
And here is my ajax,
var from_num = 130;
var to_num = 575;
var sel = "";
var nme = "";
function somethingChanged(from_num,to_num,sel,nme) {
var sel = $('.i-check:checked').map(function(_, el) {
return $(el).val();
}).get();
var nme = $('.i-check:checked').map(function() {
return $(this).attr("name");
}).get();
$.ajax({
url: 'hotelresults',
type: 'POST',
data: {
from: from_num,
to: to_num,
key: sel,
name: nme,
},
success: function(data) {
$('.hotel_list').html(data);
}
});
}
$("#price-slider").ionRangeSlider({
min: 130,
max: 575,
onChange : function (data) {
var from_num = data.fromNumber;
var to_num =data.toNumber;
somethingChanged(from_num,to_num,sel,nme);
}
});
$( ".iCheck-helper" ).on( "click", function(){
var price=$("#price-slider").val();
var myarr = price.split(";");
var from_num = myarr[0];
var to_num = myarr[1];
somethingChanged(from_num,to_num,sel,nme);
});
});
Someone help me.. Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire