Pass in an array of Deferreds to $.when()

后端 未结 9 1235
伪装坚强ぢ
伪装坚强ぢ 2020-11-21 22:20

Here\'s an contrived example of what\'s going on: http://jsfiddle.net/adamjford/YNGcm/20/

HTML:

Click me!
&l
9条回答
  •  借酒劲吻你
    2020-11-21 22:37

    If you're transpiling and have access to ES6, you can use spread syntax which specifically applies each iterable item of an object as a discrete argument, just the way $.when() needs it.

    $.when(...deferreds).done(() => {
        // do stuff
    });
    

    MDN Link - Spread Syntax

提交回复
热议问题