DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
  • Infrastructure
    • can-construct
    • can-control
    • can-event
      • static
        • addEventListener
        • bind
        • delegate
        • dispatch
        • listenTo
        • off
        • on
        • one
        • removeEventListener
        • stopListening
        • trigger
        • unbind
        • undelegate
    • can-event/async/async
    • can-event/batch/batch
    • can-observation
    • can-simple-map
    • can-util
    • can-view-callbacks
    • can-view-live
    • can-view-model
    • can-view-nodelist
    • can-view-parser
    • can-view-scope
    • can-view-target
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Infrastructure
  • /
  • can-event
  • /
  • dispatch
  • / On this page
    • dispatch

      function
      • source

      obj.dispatch(event, [args])

      Dispatches/triggers a basic event on an object.

      var canEvent = require("can-event");
      
      var obj = {};
      Object.assign(obj, canEvent);
      
      obj.addEventListener("foo", function(){
        console.log("FOO BAR!");
      });
      
      obj.dispatch("foo"); // Causes it to log FOO BAR
      

      Parameters

      1. event {String|Object}:

        The event to dispatch

      2. args {Array}:

        Additional arguments to pass to event handlers

      Returns

      {Object}:

      event The resulting event object

      canEvent.dispatch.call(obj, event, args)

      This syntax can be used for objects that don't include the can.event mixin.

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.