2012-03-28 35 views
0

我試圖創建多個定時器。任何教程,可以幫助我。最困難的部分是html部分,以及如何鏈接我的文件一個示例項目會對我很好。C#,MVC,骨幹,定時器

Html5.Views.Timer = Backbone.View.extend({ 

    el: 'div#timer', 

    initialize: function() { 
    timer = this.model; 
    this.render(); 
    }, 

    events: { 
    "clicked div#add_time": "update_timer" 
    } 

    render: function() { 
    $(this.el).append(HandlebarsTemplates['timer'](timer); 
    this.start_timer(); 
    }, 

    start_timer: function() { 
    clearTimeout(this.main_timer); 
    this.main_timer = setTimeout(function() { 
     if (this.countDownInstance) { 
     this.countDownInstance.clearRewriteCounter(); 
     } 
     this.countDownInstance = new countDown(timed.length, 'main_timer'); 
    }, timed_length*1000); 
    }, 

    update_timer: function() { 
    timed.length = timed.length+30 
    this.start_timer(); 
    } 
}); 
+0

不要重新發布的問題。 – Will 2012-04-01 04:18:33

回答

0

我覺得有一個錯字或使用timed_length或使用timed.length ..我也覺得timed.length至少應該有一個在全球範圍內被稱爲timed變量返回一個錯誤。

也行timer = this.model;是在全局範圍內聲明變量timer

另外要timed_length來電也許你想要將其更改爲this.timed_length

總結..我認爲這裏有一串打錯這裏。

+0

現在這對於像我這樣的研究生開發者來說變得複雜了,你可以爲我重寫上面的代碼是否公平? – siphab 2012-03-28 11:20:07

+1

對不起@ ak47你應該努力。 – fguillen 2012-03-28 13:24:26

+0

timed_length:function(){if(this.seconds> 0 || this.minutes> 0)this.seconds = this.seconds - 1; 如果(this.seconds == 0){ this.minutes = this.minutes - 1; this.seconds = 59;其他{ this.seconds = this.seconds - 1; }} ,但它是不是還:( – siphab 2012-03-28 13:51:29