每个设置超时确认最后一次加载并设置一个功能

时间:2017-02-11 20:25:08

标签: jquery

data(World, metro)
metro$growth <- (metro$pop2020 - metro$pop2010) / (metro$pop2010 * 10) * 100

ttm()
tm_shape(metro) +
    tm_bubbles("pop2010", col = "growth", 
               border.col = "black", border.alpha = .5, 
               style="fixed", breaks=c(-Inf, seq(0, 6, by=2), Inf),
               palette="-RdYlBu", contrast=1, 
               title.size="Metro population", 
               title.col="Growth rate (%)", id="name", 
               popup.vars=c("Population (2010)"="pop2010", "Population (2020)"="pop2020", "Growth (%)"="growth"),
               popup.format=list(growth=list(digits=4)))

我已经在每个内部设置了一个超时,我希望每个功能都按每个设置,每个设置一个2000的时间,所以它会逐个创建,问题现在是,我需要确保最后一个每个完成加载 prototype_loop 然后我需要在完成后设置其他函数,比如jQuery promise

功能过程

var J_lis = $(".display");

//J_lis.length = 4;

function test(){}

test.prototype._create = function(){
 alert("create");
}

test.prototype._loop = function(){
this._create();
}

test.prototype._set = function(){
var that = this;
J_lis.each(function(g,ele){

  var setSrc = this.src;
  var setId = this.id;
    setTimeout(function() {
      that._loop(setId, setSrc);
    }, (g+1)*2000);
}).promise().done(function () { alert("Everything is done."); });
}

确认加载的最后一个显示并为其设置功能。<​​/ p>

我如何实现这一目标? jQuery承诺刚刚在这里工作。

0 个答案:

没有答案