How to determine if jQuery UI slider has been changed programmatically or by user?

I am using jQuery UI Slider. I need to know if the slider change event is the result of a user action or a programmatic change.

At http://jqueryui.com/demos/slider/#method-option it was recommended to use the event.orginalEvent property to determine if a value has changed with the mouse, keyboard, or programmatically. But I always get this value as "undefined". I use it as stated in the link http://forum.jquery.com/topic/slider-event-originalevent

Please, help.

+2


a source to share


2 answers


I managed to get the event type with the following code:

$(document).ready((function() {
            $("#slider").slider(
            {
                slide: function(e) {
                    alert(e.originalEvent.type);
                }
            });
        }));

      



the result was a "mousemove" warning on every slide.

Check carefully in case JavaScript is a case sensitive language and if you tried to access the original but with a capital letter it will return undefined.

0


a source


" event.originalEvent " is not "event.orginalEvent". ( i is missing!).

Use e.originalEvent.type

(eg Genady said) to find out the origin of an event.



0


a source







All Articles