JQuery

Delayed object-deferred.promise([type],[target])

Delayed object-deferred.promise([type],[target]), someone asked me to explain?

deferred.promise([type],[target])

Overview

Returns a Promise object used to observe when all actions of a certain type are bound to the collection, whether they are queued or not.

The .promise() method returns a dynamically generated Promise object that is used to observe when all actions of a certain type are bound to the collection, whether it is queued or not.

By default, type is "fx" , which means that when the selected element has finished all animations, the Promise returned is resolved.

Solve the context and the only parameter is which collection is called to .promise().

If the target is supplied, .promise() will attach to its method and then return this object instead of creating a new one. This is very useful for attaching Promise to an already existing object.

parameter

type String V1.6

String to be processed

targetObjectV1.5

Object with a promise method

Example

description:

A promise is used on a collection, and no animation is resolved.

jQuery code:
 var div = $("<div />");
     div.promise().done(function(arg1) {
        // will fire right awayand alert "true"
        alert(this=== div && arg1 === div);
   });

 

 

Post your comments / questions