i have a jquery slider control with a tooltip. user can either slide to change value which adjusts the tooltip, or the user can enter the value in the textbox and the slider and tooltip should adjust value in the textbox.
see attached jfiddle http://jsfiddle.net/k2sarah/caUku/2/.
<div id='slider'></div>
<div id='slider2'></div>
<input id='t1' type='text' />
var initialValue = 2012;
var sliderTooltip = function(event, ui) {
var curValue = ui.value || initialValue;
var target = ui.handle || $('.ui-slider-handle');
var tooltip = '<div class="tooltip"><div class="tooltip-inner">' + curValue +
'</div><div class="tooltip-arrow"></div></div>';
$(target).html(tooltip);
}
$('#t1').change(function () {
var value = $('input[id$=t1]').val();
$("#slider").slider("value", parseInt(value));
sliderTooltip;
});
$("#slider").slider({
value: initialValue,
min: 1955,
max: 2015,
step: 1,
create: sliderTooltip,
slide: sliderTooltip
});
var sliderTooltip1 = function(event, ui) {
var curValue1 = ui.value || initialValue;
var target = ui.handle || $('.ui-slider-handle');
var tooltip = '<div class="tooltip"><div class="tooltip-inner">' + curValue1 +
'</div><div class="tooltip-arrow"></div></div>'; $(target).html(tooltip);
}
$("#slider2").slider({
value: initialValue,
min: 1955,
max: 2015,
step: 1,
create: sliderTooltip1,
slide: sliderTooltip1
});
following code adjusts the value of slider but not cause tooltip value to be reflected to current slider value.
$('#t1').change(function () {
var value = $('input[id$=t1]').val();
$("#slider").slider("value", parseInt(value));
sliderTooltip;
});
any help would be appreciated.
thks ken