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

Issues when using .slider class for slider handle

Open PeterTheOne opened this issue 9 years ago • 6 comments

I was using .slider class for my slider handle element like this <div class="slider"></div> and then I had problems when calling $('.slider').slider('setValue', 5);. I got a cannot call methods on slider prior to initialization error, this is because one of the elements bootstrap-slider creates has a .slider class.

It would be nice to have a warning about this in the readme.md or to change the class name to something less common. ^^

PeterTheOne avatar Sep 11 '15 23:09 PeterTheOne

I think it's easier for you to add .slider-container (instead of .slider -- it's more explicit as to what it does) or hold references separately, sorry. The error is there to let you know something's going wrong.

seiyria avatar Sep 11 '15 23:09 seiyria

yes, you're right, I shouldn't have called it .slider, but I think it's a common mistake to make. The error itself is not a problem, a note about this in the readme would be nice never the less.

PeterTheOne avatar Sep 12 '15 00:09 PeterTheOne

I had exactly the same issue by giving my slider container-div's the "slider" class. Would be nice if the internal slider classes are less obvious to override.

dionoid avatar Sep 17 '16 21:09 dionoid

Or maybe use some kind of prefix for the slider class name.

PeterTheOne avatar Sep 18 '16 08:09 PeterTheOne

Would some sort of console warning be good to indicate to the developer that the classname they selected for the slider container is invalid?

rovolution avatar Sep 18 '16 21:09 rovolution

@rovolution Console warning would be a big improvement! Maybe with reference to the doc. (Can we reopen this issue ^^)

PeterTheOne avatar Sep 19 '16 08:09 PeterTheOne