Reputation: 2051
I use bootstrap slider and looking for a way to set a value of the handle from an other variable , I found this method, but didn't work with me.. data-slider-value is the attribute that contains the value html
<input id="gravite" name="gravite" type="text"
data-provide="slider"
data-slider-ticks="[1, 2, 3]"
data-slider-ticks-labels='["Faible", "Moyenne", "Urgent"]'
data-slider-min="1"
data-slider-max="3"
data-slider-step="1"
data-slider-value=""
data-slider-tooltip="hide" />
javascript
var val=$(this).attr('gravite');
$("#gravite").slider('setValue',val);
Upvotes: 1
Views: 1058
Reputation: 935
data-provide="slider"
allows not to write any javascript code. The only thing is that you need to put the dependency on javascipt for bootstrap-slider (https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/6.1.7/bootstrap-slider.min.js) in the end of your html (for example, just before ). Also note that it must be version 6.1.7 or higher!
Upvotes: 1