Javascript event simulation library - Stack Overflow

Do you know a JS library for DOM events simulation? I know that this operation can be done but i can�

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 click, i'm looking for a library that helps me with this operation.

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 click, i'm looking for a library that helps me with this operation.

Share Improve this question edited Jan 12, 2014 at 15:08 kangax 39.2k13 gold badges100 silver badges135 bronze badges asked Mar 26, 2010 at 16:01 mck89mck89 19.3k17 gold badges91 silver badges110 bronze badges 4
  • I mean javascript can simulate an event like the user click. I want to know if there's a library to simplify this operation. – mck89 Commented Mar 26, 2010 at 16:03
  • Please clarify if simply calling handlers attached to an element is good enough "simulation" for you. – Crescent Fresh Commented Mar 26, 2010 at 16:07
  • The event simulation allows you to specify some details to build the event object to pass into the hendlers, so it's a little more plex. – mck89 Commented Mar 26, 2010 at 16:19
  • yep, and some libraries (jQuery) simulate events with a fake event object and simply call the handlers attached to the element (faking out event bubbling too). Other libraries (eg Prototype, YUI) route to one of dispatchEvent/fireEvent with a real event object. There are pros and cons to both approaches. Which one are you looking for? – Crescent Fresh Commented Mar 26, 2010 at 16:31
Add a ment  | 

4 Answers 4

Reset to default 5

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

http://developer.yahoo./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 remended 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});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742310878a4419866.html

相关推荐

  • Javascript event simulation library - Stack Overflow

    Do you know a JS library for DOM events simulation? I know that this operation can be done but i can�

    14小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信