filterrific
filterrific copied to clipboard
Issue with slider
I am using a jquery slider and having some issue:
- The result is refresh when I am moving the slider
- Multiple queries are generated
What I am trying to archive is the search only happens when the mouse is unclick and the slider value is final.
Any thoughts?
@tscung filterrific inputs by default submit the form on change. I have a hunch that your slider library updates the field value as you move it, and at every change, the form is submitted.
You can disable the AJAX auto submit and define your own observer on mouseup. Look at the Disable AJAX auto form submits section in the documentation for more info.
@tscung I'm also trying to implement a slider with filterrific? Would you mind sharing what you did for the view? I can't get the draggable handle bar to appear using f.text_field.
HTML: <%= f.text_field :hourly_rate, :class => 'slider-range' %>
JS: $( ".slider-range" ).slider({ range: true, min: 0, max: 100, step: 5, values: [ 0, 100 ], slide: function( event, ui ) { $( ".slider-amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] ); } });
make sure the value only update when stop (sliding)
slide: function (event, ui) { $("#res_page").val(ui.value + " per page"); }, stop: function (event, ui) { $("#filterrific_with_per_page").val(ui.value); }
thanks for the tip, i figured it out though, needed to use range_field instead of text_field