Please help me with this jquery-ui-slider! The time value in the tooltip is created with the initial time values; the value changes through the way moving with the mouse from A to B; at B before mouse goes up, the value differs to the value that shows afterwards; with other words the script generates two values during sliding and stopping and when mouse goes up; the moved position B value differs slightly from the position B end value after mouse up;
a possible solution: replace .slider("values", 0)... with ui.values[0] jQuery UI Slider - Value returned from 'slide' event on release is different from 'change' value
is it a solution and how can we do this for this slider? have someone an idea? please help!
//jquery ui slider with two tooltips shows seconds
$(function() { var initialTime1 = 28800; var initialTime2 = 57600;
//object with html-tooltip and value in seconds
var valtooltip = function(sliderObj, ui){ val1 = '<span class="slider-tip">'+sliderObj.slider("values", 0) + '</span>'; val2 = '<span class="slider-tip">'+sliderObj.slider("values", 1) + '</span>'; sliderObj.find('.ui-slider-handle:first').html(val1); sliderObj.find('.ui-slider-handle:last').html(val2); }; $("#slider_time").slider({ min: 0, max: 86400, step: 300, // 300s steps values: [initialTime1, initialTime2], range: true, // two sides create: function(event,ui){ valtooltip($(this),ui); }, slide: function(event,ui){ valtooltip($(this),ui); // values for hidden inputs for (var i = 0; i < ui.values.length; ++i) { //values for tooltip 0 and 1 $(".sliderValue[data-index=" + i + "]").val( ui.values[i]); //values for value in hidden inputs $(".sliderValue[data-index=" + i + "]").attr('value', ui.values[i]); } }, stop: function(event,ui){ valtooltip($(this),ui); } }); });