Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery callbacks.fireWith() method

jQuery callbacks.fireWith() method

jQuery Miscellaneous MethodsjQuery Miscellaneous Methods

Example

Access all callbacks in the list with the given context "window" and an array of arguments

$

(

function

(

)

{

//

A simple function to be added to the list

var

log

=

function

(

value1

,

value2

)

{

alert

(

"

Received:

"

value1

"

,

"

value2

)

;

}

;

var

callbacks

= $.

Callbacks

(

)

;

//

Add a function to the list

callbacks

.

add

(

log

)

;

//

Call the callback list with the context "window"

//

and an array argument

callbacks

.

fireWith

(

window

,

[

"

foo

"

,

"

bar

"

]

)

;

//

Output: "Received: foo, bar"

}

)

Try it »


Definition and Usage

The callbacks.fireWith() function is used to access all callbacks in the list with a given context and arguments.


Syntax

callbacks.fireWith( [context ] [, args ] )

Parameters Description
context A reference to the context in which the callback list is fired
args An argument or list of arguments passed back to the callbacks

jQuery Miscellaneous MethodsjQuery Miscellaneous Methods