Reputation: 1149
below is my code for jquery slider ....
function slide_temp(min,max){
$('#myrange_range').noUiSlider({
start: [min, max],
connect: true,
range: {
'min': 16,
'max': 30
},
orientation: 'vertical',
behaviour: 'tap-drag',
margin: 1,
setp: 1,
format: wNumb({
decimals: 0
}),
direction: "rtl"
});
}
I have to call this function on every <li>
click by passing min and max parameters
First Clicks it works well but from second click on words I get and error on console and clider stops working...
Uncaught Error: Slider was already initialized.
Is there any ways to uninitialize plugin ?? and any other way to fix this problem?
Upvotes: 1
Views: 1431
Reputation: 6722
Initialize the slider outside of your function
$('#myrange_range').noUiSlider({
start: [minval, maxval], // Pass your init values here.
connect: true,
range: {
'min': 16,
'max': 30
},
orientation: 'vertical',
behaviour: 'tap-drag',
margin: 1,
setp: 1,
format: wNumb({
decimals: 0
}),
direction: "rtl"
});
Then create a function which updates the values [make sure to call updateSlider
after the plugin is initialized]
function updateSlider(min,max){
$('#myrange_range').val([min,max]);
}
Upvotes: 2
Reputation: 3923
Try this:
$( "#myrange_range" ).noUiSlider( options, true /* Allow destruction + rebuilding */ );
Upvotes: 0