2012-03-28 3 views
0

여러 타이머를 만들려고합니다. 나를 도울 수있는 자습서. 가장 어려운 부분은 html 부분이며 샘플 프로젝트를 연결하는 방법은 나에게 도움이 될 것입니다. 또한 내가 timed.length가해야 적어도 전역 범위에 timed라는 변수가 오류를 반환 생각 ..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를 사용합니다.

또한 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