Backbone.js 如何停止在主干中提取集合

Backbone.js 如何停止在主干中提取集合,backbone.js,Backbone.js,磁盘是我的收藏对象。我需要停止提取集合 customPoll: function(time){ var set_time = 0; if(time === undefined){ set_time = 4000; } var route = Backbone.history.fragment.split('/'); var self = this;

磁盘是我的收藏对象。我需要停止提取集合

customPoll: function(time){
          var set_time = 0;
            if(time === undefined){
                set_time = 4000;
            }
            var route = Backbone.history.fragment.split('/');
            var self = this;
            if(route[0] === "disks"){
                setTimeout(function() {
                    Disks.fetch({update:true,success: function(){
                        self.customPoll();
                    }, error: function(){
                        self.customPoll();
                    }
                    });
                }, set_time); //TODO Need to handle efficiently...
            }  
        }
我尝试每4秒钟调用一次此抓取,如果存在其他情况,我需要停止调用此抓取

    var route = Backbone.history.fragment.split('/');
            var smart = new Smart.model({
                "id"    : route[1]
            });
            var self = this;
    smart.save(null,{
                    success: function(model,event,response){
                        model =  Disks.get(route[1]).toJSON();
                        $('#smart-confirm-dialog').modal('hide'); 
                        self.showStatusMsg(1,"<b> S.M.A.R.T. Test : </b>S.M.A.R.T Test started succesfully");
                        if(model.smart.progress === "100%"){
                            self.clearAllTimeout();
                            alert("please stop fetching....pleaseeee");
                            // Stop polling here . then fetch information from smart.fetch api.
                           Smart.fetch({update: true}); //this is another api i need to call this api now.
                        }else{
                            self.customPoll();
                        }
});
var-route=Backbone.history.fragment.split('/');
var smart=新的smart.model({
“id”:路线[1]
});
var self=这个;
smart.save(null{
成功:功能(模型、事件、响应){
model=Disks.get(路由[1]).toJSON();
$(“#智能确认对话框”).modal('hide');
self.showStatusMsg(1,“S.M.A.R.T.测试:S.M.A.R.T.测试成功启动”);
如果(model.smart.progress==“100%”){
self.clearAllTimeout();
警报(“请停止提取……请查看”);
//停止在此轮询。然后从smart.fetch api获取信息。
Smart.fetch({update:true});//这是我现在需要调用的另一个api。
}否则{
self.customPoll();
}
});

但它似乎不起作用…它一直在抓取集合..我如何才能停止此磁盘集合的抓取。

我的回答可能很有趣,我想添加注释,但我不能。你能为模型添加新字段吗

    var route = Backbone.history.fragment.split('/');
            var smart = new Smart.model({
                "id"    : route[1]
            });
            var self = this;
    smart.save(null,{
                    success: function(model,event,response){
                        model =  Disks.get(route[1]).toJSON();
                        $('#smart-confirm-dialog').modal('hide'); 
                        self.showStatusMsg(1,"<b> S.M.A.R.T. Test : </b>S.M.A.R.T Test started succesfully");
                        if(model.smart.progress === "100%"){
                            self.clearAllTimeout();
                            alert("please stop fetching....pleaseeee");
                            // Stop polling here . then fetch information from smart.fetch api.
                           Smart.fetch({update: true}); //this is another api i need to call this api now.
                        }else{
                            self.customPoll();
                        }
});
customPoll: function(time){
   var  disks = this.model.toJSON();
   if(disks.yourField){
       // here your code
   }
}

但是,在保存模型之前,需要执行删除磁盘的操作。yourField;

我的回答可能很有趣,我想添加注释,但我无法添加。您能为模型添加新字段并

customPoll: function(time){
   var  disks = this.model.toJSON();
   if(disks.yourField){
       // here your code
   }
}
但是在保存模型之前,需要执行
删除磁盘。yourField;