1

我正在一个小型示例应用程序上学习 ember.js,但最后一块我无法开始工作。

我有一个“俏皮话”(推文)列表,并且有一个文本输入字段允许创建一个新字段。提交新推文后,我想清除文本输入,但无济于事。在这一点上,我基本上逐字复制了todomvc 示例并且它在那里工作(我什至使用相同的 ember.js 和 ember-data.js 版本只是为了排除这种可能性)。

这是模板:

<script type="text/x-handlebars" data-template-name="index">
    <h2>Latest Quips</h2>
    <div>
            {{view Ember.TextField id="new-quip" placeholder="Enter your Quip"
            valueBinding="newQuip" action="createQuip"}}
    </div>

相应控制器中的操作:

App.IndexController = Ember.ArrayController.extend({
  createQuip: function() {
    App.Quip.createRecord({
      text: this.get('newQuip'),
      user: 'ree'
    });
    this.set('newQuip', ''); // this row should clear the view
    this.get('store').commit();
  }
});

为了完整起见,模型:

App.Quip = DS.Model.extend({
  text: DS.attr('string'),
  user: DS.attr('string')
});

App.Store = DS.Store.extend({
    revision: 11,
    adapter: 'App.QuipsAdapter'
});

App.Quip.FIXTURES = [
    { id: 1, user: 'ree', text: 'Which is the best JS MVC?' },
    { id: 2, user: 'baaz', text: '@ree Definitely Ember.js!' }
];

App.QuipsAdapter = DS.FixtureAdapter.extend({});

该应用程序在这里运行

如果有人能指出我做错了什么,我会非常高兴。

谢谢,

巴林特

4

1 回答 1

3

这是一个与 jQuery 1.9.0 相关的错误 - 尝试 v1.8.x

Also, as I can recall, it's been fixed on master, so grabbing the latest Ember release may also solve your problem.

于 2013-02-05T22:23:00.610 回答