Function. createdelegate is the most common method for function encapsulation. Function signature:
Function. createdelegate (instance, method)
This method returns a callback function.
For example:
Fireafter: function (seconds)
{
SetTimeout (function. createdelegate (this, this. _ timeoutcallback), seconds * 1000 );
},
If a function is directly handed over to some HTML controls as the callback function, the object referenced by this is the control when an event occurs, rather than the custom object. For example, a function is handed over to window. after setTimeout, This is the window. Function. createdelegate solves this problem. It is recommended that you use this method to respond to the callback of the HTML control. It ensures that when the method parameter references the method to be called, this must reference the instance parameter object.
Transferred from: http://aloneplayer.spaces.live.com/blog/cns! C3cb6d654135f83d! 371. Entry