dojo.hitch
<script src="../../js/dojo.js"></script>
defined in dojo/_base/lang.js
Returns a function that will only ever execute in the a given scope. This allows for easy use of object member functions in callbacks and other places in which the "this" keyword may otherwise not reference the expected scope. Any number of default positional arguments may be passed as parameters beyond "method". Each of these values will be used to "placehold" (similar to curry) for the hitched function.
parameter | type | description |
---|---|---|
scope | Object | to be hitched. |
method | Function | Repeating. A function to be hitched to scope, or the name of the method in |
Examples
Example 1
dojo.hitch(foo, "bar")();
runs foo.bar() in the scope of foo
Example 2
dojo.hitch(foo, myFunction);