Closed CodeCurosity closed 4 years ago
Hi, you can't reset it like this. You should manually call sliders reset()
method. Like this:
var $slider = $(".form").find(".js-range"); // replace js-range with your class name
var slider_instance = $slider.data("ionRangeSlider");
slider_instance.reset();
It works perfectly if you have single slider instance, how do we reset if there are multiple?
Figured it out, hope this helps others.
var sliders = $(".form").find(".range_slider");
jQuery(sliders).each(function(index,slider){
var slider_instance = jQuery(slider).data("ionRangeSlider");
slider_instance.reset();
});
Figured it out, hope this helps others.
var sliders = $(".form").find(".range_slider"); jQuery(sliders).each(function(index,slider){ var slider_instance = jQuery(slider).data("ionRangeSlider"); slider_instance.reset(); });
Thanks for your reply, it helped me solve this problem too :) Based on that I decided to do a for loop instead of a .each (I feel more comfortable with that) and run it in every element with the class associated with the slider. Here it goes:
var num=$(".js-range-slider").length; for(var i=0;i<num;i++){ var sliderFromTo=$(".js-range-slider:eq("+i+")").data("ionRangeSlider"); sliderFromTo.reset(); }
how can we reset the slider to its original predefined values on ajax form submission?
I am resetting my form with a trigger, it resets all other fields but range slider.
jQuery('.form').trigger("reset");