$ .when (2 conditions). then (function () {});

I want to make:

$.when(app.loadDevice && app.loadReady).then(function(){ //Execute code });` 

But my code seems to be executed when the first condition is triggered using app.loadDevice.resolve ()

+4
source share
1 answer

When you use the && operator with two JavaScript objects, the result is the value of the first object, so only the one that $.when . The second object is not even evaluated.

Instead, you want to pass both objects as different arguments to the $.when function:

 $.when(app.loadDevice, app.loadReady).then(function(){ //Execute code }); 

This can be seen in some examples in the official documentation .

+6
source

Source: https://habr.com/ru/post/1501866/


All Articles