Latest web development tutorials

jQuery .promise () method

jQuery Misc Methods jQuery Misc Methods

Examples

.promise Call on a movie set is not activated ()

$ (Function () { var div = $ ( "<Div />" );.. Div promise () done (function ( arg1 ) { // Pop "true" alert ( this === div && arg1 === div );});})

try it"

Definition and Usage

.promise () function returns a Promise object to observe some type of action is bound to all collections, whether it has been added to the queue.


Note: 1. .promise () method returns a dynamically generated Promise, when bound to the collection of all the specific actions (action) has been added or not added to the queue, the resulting Promise will be accepted (resolve) .
The default value is 2. type "fx", which means to be entertained (resolve) the Promise objects are selected when all the elements are completed animation returned.
3. If you supply target parameters, .promise () method to add on that parameter, and then return the object, instead of creating a new one. It applies to a situation on an object that already exists to add Promise behavior.


grammar

.promise( [type ] [, target ] )

参数 描述
type String类型 需要待观察队列类型。
target PlainObject类型 将要绑定 promise 方法的对象。


Examples

More examples

Call accept returns of Promise end of the animation
When all the end of the animation (including those in the animation callback and then add the callback function initialized animation), receiving (Resolve) returned Promise.

Use $ .when () statement accepting returned Promise
Use $ .when () statement (.promise () method so that it becomes possible to achieve in the jQuery collection), receiving (Resolve) returned Promise.


jQuery Misc Methods jQuery Misc Methods