How to fire a callback function after a for-loop is done in Jquery?

前端 未结 1 1979
星月不相逢
星月不相逢 2020-12-20 00:43

I have two functions that caluclate and adjust the height and width of elements on screen.

panelHeight sets the height of target elements to the ava

相关标签:
1条回答
  • 2020-12-20 00:49

    This is the purpose of the JQuery Deferred...

    var deferred = $.Deferred();
    
    somethingAsync(function() {
        // callback stuff here
    
        // now tell the deferred task it's ok to proceed
        deferred.resolve();
    }
    
    deferred.done(function() {
        // your finalize code here
    });
    

    Edit Since the resolve event needs to be tied to a dom resizing, maybe the Javascript resize event handler would work.

    0 讨论(0)
提交回复
热议问题