IonDen / ion.rangeSlider

jQuery only range slider
http://ionden.com/a/plugins/ion.rangeSlider/en.html
MIT License
2.56k stars 508 forks source link

How do I write RESET for IonRangeSlider correctly? #729

Open Jeka-EKB opened 4 years ago

Jeka-EKB commented 4 years ago

How do I write a function for the RESET button to reset from and to to the initial settings without overloading the page? Version of IonRangeSlider v2.3.1 I Read the instructions but couldn't find a real answer, I'm just learning JS. Please help with this issue.

<div class="slider-container">
<form action="" method="post">
<input type="text" id="slider">
<input class="value1" name="prmfr">
<input class="value2" name="prmto">

<input type="reset" value="RESET" onclick="myreset()">
</form>
</div>

<script>
$("#slider").ionRangeSlider({
    min: 1,
    max: 50,
    from: 10,
    to: 40,
    type: "double",
    step: 5,
    skin: "big",
    min_interval: 5,
    grid: true,
    grid_num: 10,

    onFinish(data) {
    data.input.closest('.slider-container').find('.value1').val(data.from);
    data.input.closest('.slider-container').find('.value2').val(data.to);
    }
});
function myreset() {
    ????????????????????????
}
</script>
</div>
IonDen commented 4 years ago
var mySlider = $("#slider").data("ionRangeSlider");
function myreset() {
  mySlider.reset();
}
Jeka-EKB commented 4 years ago

The code works, but there is a problem. Added the filter button (it displays sorted pages) and then RESET resets to the to old values. And how can I make sure that all MIN MAX from TO values are restored ?

Jeka-EKB commented 4 years ago

Resets to old values but not initial values

IonDen commented 4 years ago

Then you need to store original values in a separate variables, and instead of reset() do slider update({from: x, to: y})

Jeka-EKB commented 4 years ago

Please tell me how and where to write it? I don't know much about JS and can't do it right.

IonDen commented 4 years ago

This question is already not related. You should ask it on StackOverflow, Toster.ru etc.