Home  >  jQuery

Example of callbacks.fire() in jQuery

March 30, 2013
fire() in jQuery is called on callback list. Callback list can contain methods to be called. callbacks.fire() calls the callback methods added in callback list. It is called as
callbacks.fire();
 
It is called as

<html>
<body>

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

<script>

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

var cal = function(a,b) {
	console.log(a+b);
};

var callbacks = $.Callbacks();

callbacks.add( show );

callbacks.fire( "Hello World!" );

callbacks.empty();

callbacks.add(cal);

callbacks.fire( 5,3);

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

Output
In console output will look like
Hello World!
8
 
FIND MORE TUTORILAS






©2019 concretepage.com | Privacy Policy | Contact Us