Easy Tutorial
❮ Traversing Filter Jquery Plugin Message ❯

jQuery callbacks.fire() Method

jQuery Miscellaneous Methods

Example

Invoking all callbacks with the specified arguments.

$(function () { 
    // A simple function that will be added to the list
    var foo = function( value ) {
          alert( "foo:" + value );
    };     
    var callbacks = $.Callbacks(); 
    // Add the function "foo" to the list
    callbacks.add( foo ); 
    // Invoke all callbacks in the list with the argument "hello"
    callbacks.fire( "hello" ); // Output: "foo: hello"
    callbacks.fire( "world" ); // Output: "foo: world"     
    // Add another function to the list
    var bar = function( value ){
      alert( "bar:" + value );
    };
    // Add this function to the list
    callbacks.add( bar ); 
    // Invoke all callbacks in the list with the argument "hello again"
    callbacks.fire( "hello again" );
    // Output:
    // "foo: hello again"
    // "bar: hello again"
})

Definition and Usage

The callbacks.fire() function is used to invoke all callbacks with the specified arguments.

This method returns the callback object to its bound callback list.


Syntax

Parameter Description
arguments Any type, the arguments to pass back to the callback list

jQuery Miscellaneous Methods

❮ Traversing Filter Jquery Plugin Message ❯