2012-03-28 15 views
0

複数のタイマーを作成しようとしています。私を助けることができるチュートリアル。最も難しいのはhtmlパーツで、サンプルプロジェクトで私のファイルをリンクする方法は私には良いことです。c#、mvc、backbone、timer

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

答えて

0

また、私はtimed.lengthがすべきだと思う..私はタイプミスがあると思いますかあなたはtimed_lengthを使用するか、timed.lengthを使用すると、エラーが、少なくともグローバルスコープでtimedという変数がある返します。

また、timer = this.model;という行は、グローバルスコープ内で変数timerを宣言しています。

また、timed_lengthへの呼び出しをthis.timed_lengthに変更することもできます。

ここにはのタイプミスがあります。はこちらです。

+0

これは、私のような大学院の開発者にとっては、上記のコードを私のために書き直すことができますか? – siphab

+1

申し訳ありません@ ak47あなたは努力する必要があります。 – fguillen

+0

timed_length:function(){if(this.seconds> 0 || this.minutes> 0){ this.seconds = this.seconds - 1; if(this.seconds == 0){ this.minutes = this.minutes - 1; this.seconds = 59; } else { this.seconds = this.seconds - 1; } } しかし、それはまだ動作していません:( – siphab