I have created my jquery price slider but I am not sure how to filter my results so that as you slide you only see the products with that value in range.
HTML:
<div class="demo">
<p>
<label for="amount">Price range:</label>
<input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;" />
</p>
<div id="slider-range"></div>
<ul>
<li> product - £10 </li>
<li> product - £50 </li>
<li> product - £100 </li>
<li> product - £150 </li>
<li> product - £200 </li>
</ul>
</div>
JavaScript:
$(function() {
var options =
{
range: true,
min: 0,
max: 500,
values: [ 50, 300 ],
slide: function( event, ui ) {
$( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
}
};
$( "#slider-range" ).slider(
options
);
$( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
" - $" + $( "#slider-range" ).slider( "values", 1 ) );
});
My fiddle is http://jsfiddle.net/ktcle/uvJ8F/
I would make a few changes:
Give your list of products an
id
attribute and give each product adata-price
attribute that is equal to the price of the item:Add a function that will show or hide those products when a
slide
event occurs:Call that function from the
slide
event handler:Also call that function right after the slider is initialized so that the correct products are hidden initially:
The entire snippet:
Example: http://jsfiddle.net/5aPg7/