jQuery UI Slider - Disable click on slider track

后端 未结 13 1372
南方客
南方客 2020-12-31 08:57

I\'m trying to find a way to disable the click on my jQuery UI Slider\'s track. Clicking on the handle is ok but I do not want the handle to respond if the user clicks on t

13条回答
  •  忘掉有多难
    2020-12-31 09:09

    Having spent a while looking for a solution or something that would help get me closer to what I was after, I came up with the following, which appears to work in all browsers:

        var _sliderEvents = [];     
    
        $('.slider').each(function (i) {
            var _slider = $(this);
            _sliderEvents.push($._data(_slider[0]).events.mousedown);
            $._data(_slider[0]).events.mousedown = {};
            _slider.on({
                mouseenter: function () {
                    $._data(_slider[0]).events.mousedown = _sliderEvents[i];
                },
                mouseleave: function () {
                    $._data(_slider[0]).events.mousedown = {};
                }
            }, '.ui-slider-handle');
        });
    

    http://jsfiddle.net/digits/fxef8398/ You're welcome :)

提交回复
热议问题