jQuery callbacks.lock() method
Example
Use callbacks.lock() to lock a callback list to prevent further changes to its state
$
(
function
(
)
{
//
A simple function to be added to the list
var
foo
=
function
(
value
)
{
alert
(
"
foo:
"
value
)
;
}
;
var
callbacks
= $.
Callbacks
(
)
;
//
Add a function to the list
callbacks
.
add
(
foo
)
;
//
Call all callbacks in the list with the given arguments
callbacks
.
fire
(
"
hello
"
)
;
//
Output "foo: hello"
//
Lock the callback list
callbacks
.
lock
(
)
;
//
Try to call the callback list again
callbacks
.
fire
(
"
world
"
)
;
//
When the list is locked, no items can be called, so "world" will not be passed in for execution
}
)
Try it »
Definition and Usage
The callbacks.lock() function is used to lock a callback list in its current state.
**Note:** 1. If a callbacks object is created with the "memory" flag as its argument, bound functions may be added and fired after the callback list has been locked.
2. This method returns a callbacks object to the callback list it is bound to.
Syntax
This method does not accept any parameters.
callbacks.lock()
More examples
Create a callbacks object using "memory" as the argument
Create a callbacks object using "memory" as the argument, and then view the list.
jQuery Miscellaneous Methods