I am usi开发者_运维知识库ng 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.
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.
It is "event.originalEvent" not "event.orginalEvent". (i is missed !).
Use e.originalEvent.type
(like Genady said) to find out the event origin.
精彩评论