Ive been trying to get with JQuery UI slider the following to work.
Ive got 2 sliders, one is a amount the other is a duration. When the amount is lower then 200 you can select 15 and 30 days. If the amount is higher than 200 only 30 days and the slider should disable.
Ive been trying a lot, you can see my experiments at jsfiddle. http://jsfiddle.net/prommetheus/jatcrsxv/
$('#howmuch_sld').slider({
range: "min",
value: 300,
min: 50,
step: 50,
max: 600,
slide: function(event, ui) {
$('#amt').html('€' + ui.value);
}
});
$('#amt').html('€' + $('#howmuch_sld').slider('value'));
$('#howlong_sld').slider({
range: "min",
value: 15,
min: 15,
step: 15,
max: 30,
slide: function(event, ui) {
if($('#howmuch_sld').slider('value') > '200'){
$('#howlong_sld').slider({
value: 30,
min: 15,
step: 15,
max: 45, // TO CENTER SLIDER HANDLER
disabled: true,
});
};
$('#day').html(ui.value + '<span class="small"> days</span>');
}
});
$('#day').html($('#howlong_sld').slider('value') + '<span class="small"> days</span>');
I hope someone can help me on the right way!
From what I understand, your validation is in the wrong
slide
event. It should be during the amountslide
since that's what will have an effect. And instead of redoing theslider
on slide, you can change theoptions
after it's been created. Something like this should get you closer to your objective:http://jsfiddle.net/tmcyzcvc/1/