开发者

Javascript event simulation library

开发者 https://www.devze.com 2022-12-24 01:58 出处:网络
Do you know a JS library for DOM events simulation? I know that this operation can be done but i can\'t find any library to do it.

Do you know a JS library for DOM events simulation? I know that this operation can be done but i can't find any library to do it.

UPDATE: I try to explain better my question. Javascript can simulate events like the user 开发者_如何学Goclick, i'm looking for a library that helps me with this operation.


Kangax made a very useful set of extensions for the PrototypeJS framework, the one that might interest you is Event.simulate


http://developer.yahoo.com/yui/3/event/#eventsimulation

""" Simulated events are browser-created events that, most of the time, behave exactly as user-initated events. Events bubble as they normally would and event objects are created with properties containing data about the event (sometimes these properties are browser-specific, so it's recommended that you make use of the browser-equalizing methods of Y.Event to retrieve the appropriate values for properties such as target, relatedTarget, and charCode. All event handlers are called synchronously at each event target throughout the event's lifetime. Events are simulated using the simulate() method on any Y.Node instance. """


All of the major javascript libraries have the ability to trigger events. To add to the chorus of examples, in jquery you do it with: $("target_element").trigger("an_event");


You can use prototype.js to fire your own custom events

e.g. treeContainer.fire('nodeIcon:mousedown', {targetEvent: event, node: node});

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号