Home  >  jQuery

Example of callbacks.lock() in jQuery

March 30, 2013
lock() in jQuery, locks the callback list and then fire() method will not work on callback list. In code it is used as
callbacks.lock()
 
Sample example is given below.

<html>
<body>

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>

<script>

var show = function( val ) {
	console.log(val);
};

var callbacks = $.Callbacks();

callbacks.add( show );

callbacks.fire("Hellow");

callbacks.lock();

callbacks.fire("World!");

</script>
</body>
</html>
 
 


Output
Hellow
 
Before calling lock, It prints Hellow in console but after calling lock(), World! will not print in console.
FIND MORE TUTORILAS






©2019 concretepage.com | Privacy Policy | Contact Us