Forums › Forums › Search & Filter Pro › How to disable 1 of the Range Slider Handle
Tagged: Handle, Hide, range slider, slider
- This topic has 11 replies, 3 voices, and was last updated 7 years, 11 months ago by Anonymous.
-
Anonymous(Private) December 7, 2016 at 7:11 am #74489
Hello,
I want to disable one of the range slider handles.
I want only one handle in the range slider. Please refer the below image. i want to remove the handle on the right side which is rounded in red colour.
Currently i have hide the second one using CSS but if we click that portion it will change.
So need a workaround to disable the range slider handle.
Ross Moderator(Private) December 8, 2016 at 6:12 pm #75172Hey Jeykumar
I’m not sure the code off the top of my head, I’ll try to have a look, but I’m sure our sliders (powered by NoUISlider) has some functions to do this.
I’ll see if I can knock something together for you… I’m away at the moment so will likely be monday, probably when I do the other fixes I mentioned too 🙂
Give me a nudge if you don’t hear from me on Monday.
Thanks
Ross Moderator(Private) December 12, 2016 at 4:12 pm #75741Hey Jeykumar
I messaged you earlier about the update sent.
In addition I figured out how to access the nouislider from outside S&F and disable a handle:
var slider = jQuery('.sf-field-post-meta-_price .meta-slider')[0]; var origins = slider.getElementsByClassName('noUi-origin'); origins[0].setAttribute('disabled', true);
Just to note,
.sf-field-post-meta-_price
is a class specific to a field in my setup – check the markup of yours to find the right class to use (this class is added on each<li>
, for every field and is related to the meta key you are using, in my case it was “_price”)Also
origins[0]
means left handle, andorigins[1]
would mean the right handle.Best
Trevor(Private) December 15, 2016 at 2:07 pm #76535Hi
You mean after Ajax is used?
If you have written the code as a separate script and given it a function name, you also need to call that after ajax has finished.
See the ajax finished example (not the others) on the FAQ page:
https://www.designsandcode.com/wordpress-plugins/search-filter-pro/faqs/
Ross Moderator(Private) December 16, 2016 at 9:46 am #76948Yup, when an ajax request completes the form is reloaded, so the script you added is no longer working.
Detect when an ajax request completes using the info at the link above:
//depending on where you add your JS, sometimes its necessary to wrap the above events in a function (as is standard practise): (function ( $ ) { "use strict"; $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ //add your script here again var slider = jQuery('.sf-field-post-meta-_price .meta-slider')[0]; var origins = slider.getElementsByClassName('noUi-origin'); origins[0].setAttribute('disabled', true); }); }(jQuery));
Thanks
-
AuthorPosts