bootstrap-slider icon indicating copy to clipboard operation
bootstrap-slider copied to clipboard

Issue when regenerating slider

Open kpagcha opened this issue 7 years ago • 1 comments

I am using a slider and a checkbox to toggle between a normal slider and a ranged one. First I tried to simply use setValue when checking/unchecking the checkbox, but as I pointed out in this issue, an exception is thrown when trying to set an array as the value.

So I was left with the only choice of initializing an entirely new component every time the checkbox was toggled. To my surprise, that did nothing. It didn't seem like the slider was regenerated at all, and the old one remained. Check it out here.

So I figured I needed to destroy the component first and then try to reinitialize it. So I tried this, and it does destroy the slider, but it just doesn't build a new one.

I have also tried using refresh but that did not switch between a normal and ranged slider, when trying to switch from a ranged one to a normal one, it would keep being a ranged slider and would use the maximum value automatically as a filler.

Is there any way I can reliably regenerate the slider? Why isn't it initializing at all?

Edit: I eventually found out a workaround for this issue, even though I don't like it at all. The only way of regenerating the slider is to remove the old input and add it again programmatically, then initialize the slider on the new element. The fact that this works and not the natural way makes me think the original input is still found to be bound to the slider (even after destroying it), so it cannot be initializated because there must be a check that prevents initializing a slider if it's already bound.

kpagcha avatar Feb 22 '17 14:02 kpagcha

I have the same problem! :sob:

phlegx avatar Jul 11 '17 10:07 phlegx