문제

I am having a strange problem with chrome.

All my inputs (type range) are not sending values when moving the slider anymore however, the value is updated just when the mousebutton is realised.

here a simple example of a slider used to update the frequency value of an oscillator.

http://jsfiddle.net/salvonostrato/aL9jg/

It was working fine 5 hours ago as all my other apps. I did not changed anything and in Safari it works just fine.

I am using a simple jquery change function to update the value.

$('#slider').change(function () {

console.log ($("#slider").val());

oscillator.frequency.value = $("#slider").val();
document.getElementById('freq').value = $("#slider").val();


});

Is it something I have to worry about and change all my projects, or is just because Chrome team is updating the servers or libraries??

thanks

도움이 되었습니까?

해결책

Yes, it looks like a recent update to chrome changed the change event to only trigger when you stop moving the handle. Fortunately you can still use the input event.

$('#slider').on("input change", function () {
    console.log($("#slider").val());
    oscillator.frequency.value = $("#slider").val();
    document.getElementById('freq').value = $("#slider").val();
});

i left "change" there for backward compatibility with browsers that don't support input, though since you're using a webkit interface, it's likely safe to just use input.

http://jsfiddle.net/aL9jg/2/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top