A
A
andy3010862015-06-17 20:52:33
JavaScript
andy301086, 2015-06-17 20:52:33

IonRangeSlider not initializing?

Good afternoon. I am using the ionRangeSlider plugin. Initialization occurs in a modal form. But when the form I reopen that values ​​remain old? Maybe someone faced this? Thank you.
Code example

(function ($) {
    $('.modal').on('shown.bs.modal', function (e) {
        $.each($(".probability"), function (key, value) {
            $(value).ionRangeSlider({
                type: 'single',
                min: 0,
                max: 100,
                postfix: '%',
                from: $(value).val(),
                step: 0.5,
                keyboard: true,
                prettify: false,
                hasGrid: true,
                grid: true,
                grid_snap: true
            });
        });
    });
})(jQuery);
:

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Ineshin, 2015-06-17
@andy301086

Most likely you are not destroying the instance properly. Try to do the following check before initialization:

var old = $(value).data("ionRangeSlider");
if (old) {
    old.destroy();
}

$(value).ionRangeSlider({
    ...

UPD:
Then differently, here I made a demo in which a new instance is created without deleting the old one: jsfiddle.net/IonDen/7cs1L93s
As you can see, everything works fine and the new values ​​are assigned perfectly. So the problem is different, in that you take the value like this: from: $(value).val(), and there it is old.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question