jQuery callbacks.lock () method
Examples
() Callback list with a lock callbacks.lock, to avoid further modify the list of state
$ (Function () {
// Will be added to the list a simple function
var foo = function ( value ) {
alert ( "Foo:" + value );}; Var . callbacks = $ Callbacks (); // add the function to the list
callbacks. add ( foo ); // Parameters passed to call all the callback list
callbacks. fire ( "Hello" ); // Output "foo: hello"
// Lock callback list
. callbacks lock (); // try to invoke the callback list again
callbacks. fire ( "World" ); // When the list is locked, you can not call any of the items, so the "world" will not be passed executed
})
try it"
Definition and Usage
callbacks.lock () function is used to lock the callback list of the current status.
Note: 1. If the callback object is created with the "memory" symbol as its parameter binding function may be added to the list after the callback is locked and triggers.
2. This method returns a callback object to the callback list it binding.
grammar
This method does not accept any parameters.
callbacks.lock()
More examples
Use "memory" as a parameter to create callback objects
Use "memory as a parameter to create a callback object, and then view the list.