YouTip LogoYouTip

Misc Callbacks Lock

# jQuery callbacks.lock() Method [![Image 4: jQuery Misc Methods](#)jQuery Misc Methods](#) ## Example Lock a callback list with callbacks.lock() to prevent further modification of the list's state. $(function(){// A simple function to be added to the list var foo = function(value){alert("foo: " + value); }; var callbacks = $.Callbacks(); // Add the function to the list callbacks.add(foo); // Fire all callbacks in the list, passing an argument callbacks.fire("hello"); // Outputs "foo: hello" // Lock the callback list callbacks.lock(); // Attempt to fire the callback list again callbacks.fire("world"); // When the list is locked, no items can be invoked, so "world" will not be passed for execution}) [Try it Β»](#) * * * ## Definition and Usage The callbacks.lock() function is used to lock the current state of a callback list. **Note:** 1. If the callback object was created with the "memory" flag as its argument, bound functions may be added and fired after the callback list is locked. 2. This method returns the callback object to its bound callback list. * * * ## Syntax This method does not accept any arguments. callbacks.lock() * * * ![Image 5: Example](#) ## More Examples (#) Create a callback object with "memory" as the argument, then view the list. * * jQuery Misc Methods](#)
← Misc Callbacks RemoveMisc Callbacks Firewith β†’