JQuery Mobile Slider disables click events, jqueryslider

Source: Internet
Author: User

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 ".

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.