c#,mvc,backbone,timer

时间:2012-03-28 06:38:57

标签: javascript backbone.js

我正在尝试创建多个计时器。任何可以帮助我的教程。最困难的部分是html部分以及如何链接我的文件示例项目对我有益。

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();
  }
});

1 个答案:

答案 0 :(得分:0)

我认为存在拼写错误或您使用timed_length或使用timed.length。我还认为timed.length应该返回错误,至少有一个名为{{1}的变量在全球范围内。

行[{1}}也在全局范围内声明变量timed

此外,您可能希望将timer = this.model;更改为timer

总结..我认为这里有一堆拼写错误