dispatch.apply()

dispatch.apply(type[, that[, arguments]])

Like function.apply, invokes each registered callback for the specified type, passing the callback the specified arguments, with that as the this context. For example, if you wanted to dispatch your custom callbacks after handling a native click event, while preserving the current this context and arguments, you could say:

selection.on("click", function() {
  dispatch.apply("custom", this, arguments);
});

You can pass whatever arguments you want to callbacks; most commonly, you might create an object that represents an event, or pass the current datum (d) and index (i). See function.call and function.apply for further information.

doc_D3_Js
2016-11-24 10:27:39
Comments
Leave a Comment

Please login to continue.