seiyria / bootstrap-slider

A slider control for Bootstrap 3 & 4.
http://seiyria.github.io/bootstrap-slider/
Other
3k stars 1.14k forks source link

Issues when using class for slider event handle #949

Closed Nugjii closed 3 years ago

Nugjii commented 3 years ago

I am try to handle slider events by class attribute because of multiple and dynamic propose. It is not working on select by class like follow:

$(".priceSlider").slider().on('slide', function(){     
  v = $(this).data('slider').getValue(); 
  console.log(v);
});

Selecting by id attribute is working fine. I have created a JSFiddle for this here: https://jsfiddle.net/mq87gnay/1/

Kenya69 commented 3 years ago

Hey Nugjii You need to remove .slider() Like `$(".priceSlider").slider({});

$(".priceSlider").on('slide', function(){
v = $(this).data('slider').getValue();
$(".price-min").val(v[0]); $(".price-max").val(v[1]); });`

Hope this helps

chamilagunawardana commented 3 years ago

Hello Kenya69, I have done remove slider and then call event, but still it wont work. Me to need to call event using class instead of id. Do we have any alternate way. @Nugjii did you find solution for that.

Regards, Chamila

Nugjii commented 3 years ago

Thanks, @Kenya69

@chamilagunawardana I have created a working JSFiddle for this here: https://jsfiddle.net/5wf98j4r/