JQuery Mobile Slider disables click events, jqueryslider
A sub-original, reprinted please indicate the source.
When using jQuery Mobile Slider, it is found that when dragging pages up or down, it is easy to trigger the Slider Click Event accidentally, resulting in misoperation. To do this, disable the Slider click event.
The official API does not provide a method to disable click events. Therefore, this function can only be implemented in a different way.
Note that when you click Slider, You need to trigger a mousedown method to change the position of the Slider. Rewrite this method to keep the original position unchanged when the mousedown event is triggered.
Implementation Method
First, find the object to be operated:
Control Code:
/***** Click events at any position of the control slider are unavailable **/
Function disableSliderTrack ($ slider ){
$ Slider. bind ("mousedown", function (event ){
Var x = event. pageX;
Var y = event. pageY;
Var $ handle = $ (this). find (". ui-slider-handle ");
Var left = $ handle. offset (). left;
Var right = left + $ handle. outerWidth ();
Var top = $ handle. offset (). top;
Var bottom = top + $ handle. outerHeight ();
Return (x> = left & x <= right & y> = top & y <= bottom );
});
}
Initialize all slider objects during page loading
$(function(){
disableSliderTrack($(".ui-slider-track"));
});
This is a success. All entries can access Rome, and the click event can be "disabled" by overwriting the control's mousedown method ".