简体   繁体   English

jQuery UI滑块,更改事件显示*太多的递归*

[英]jquery UI slider, change event show *too much recursion*

$( "#slider-1" ).slider({
        min: 1,
        step: 0.01,
        max: 3,
        value: 2,
        animate:"slow",
        orientation: "horizontal",
        change: function (event, ui) {
            $(this).slider('value', Math.round(ui.value));
            ui.preventDefault();
        }
    })

This show too much recursion error in console how fix it. 这在控制台中显示了太多的递归错误,如何解决。

thanks in advance. 提前致谢。

I fixed that issue myself, by changing the code as below. 我自己通过更改如下代码解决了该问题。

var rounded_value='';

    $( "#slider-1" ).slider({
        min: 1,
        step: 0.01,
        max: 3,
        value: 2,
        animate:"slow",
        orientation: "horizontal",
        change: function (event, ui) {
            if(rounded_value!=ui.value){
                rounded_value=ui.value;
                $(this).slider('value', Math.round(ui.value));  
            }
            return false;
        }
    })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM