filterrific icon indicating copy to clipboard operation
filterrific copied to clipboard

Issue with slider

Open tscung opened this issue 9 years ago • 4 comments

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 avatar Sep 15 '15 01:09 tscung

@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.

jhund avatar Sep 30 '15 14:09 jhund

@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 ] ); } });

lawrencetran1 avatar Oct 09 '15 21:10 lawrencetran1

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); }

tscung avatar Oct 12 '15 07:10 tscung

thanks for the tip, i figured it out though, needed to use range_field instead of text_field

lawrencetran1 avatar Oct 12 '15 07:10 lawrencetran1