views:

168

answers:

1

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

At http://jqueryui.com/demos/slider/#method-option , it was recommended to use the property event.orginalEvent to detect whether the value changed by mouse, keyboard, or programmatically. But I am always getting this value as "undefined". I am using it as mentioned in the link http://forum.jquery.com/topic/slider-event-originalevent

Please help.

A: 

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

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

as a result "mousemove" alert popped up on every slide.

Check carefully the case, JavaScript is case-sensitive language and if you have tried to access originalEvent but with capital letter it would return undefined.

Genady Sergeev
I hooked the callback to change event. After changing it to slide event, it worked. Thanks for help.
mohang