Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js 单击时操作模型属性_Ember.js - Fatal编程技术网

Ember.js 单击时操作模型属性

Ember.js 单击时操作模型属性,ember.js,Ember.js,我最近刚开始学习余烬(到目前为止有很多麻烦)。我正在尝试显示提要列表。单击某个提要时,我想在其标题后附加一个“x”。这应该在列表中立即更新 这就是我所得到的(余烬1.0版本之前) 下面是我的HTML <script type="text/x-handlebars"> <h1>Feeds</h1> <ul> {{#each App.feedsController}} {{#view App.FeedItemView fee

我最近刚开始学习余烬(到目前为止有很多麻烦)。我正在尝试显示提要列表。单击某个提要时,我想在其标题后附加一个“x”。这应该在列表中立即更新

这就是我所得到的(余烬1.0版本之前)

下面是我的HTML

<script type="text/x-handlebars">
  <h1>Feeds</h1>
  <ul>
    {{#each App.feedsController}}
      {{#view App.FeedItemView feedBinding="this"}}
        {{title}}
      {{/view}}
    {{/each}}
  </ul>
</script>
多次单击会产生以下错误:

Uncaught Error: Cannot perform operations on a Metamorph that is not in the DOM. 
Something you did caused a view to re-render after it rendered but before it was inserted into the DOM. Because this is avoidable and the cause of significant performance issues in applications, this behavior is deprecated. If you want to use the debugger to find out what caused this, you can set ENV.RAISE_ON_DEPRECATION to true.
我仔细地查找了这两个,但没有找到任何答案。通常产生这些错误的示例都不像我的代码。我还尝试以各种方式设置ENV.RAISE_ON_DEPRECATION,但仍然显示错误消息

任何帮助都将不胜感激。谢谢!:-)

解决方案:


显然,这正是让这个例子发挥作用所需要的

App.ApplicationController = Em.Controller.extend();
App.ApplicationView = Em.View.extend({
  templateName: 'application'
});

App.Router = Em.Router.extend({ 
  root: Em.Route.extend()
});

App.initialize();
App.ApplicationController = Em.Controller.extend();
App.ApplicationView = Em.View.extend({
  templateName: 'application'
});

App.Router = Em.Router.extend({ 
  root: Em.Route.extend()
});

App.initialize();
模板定义应该有一个名称

<script type="text/x-handlebars" data-template-name="application">
<script type="text/x-handlebars" data-template-name="application">


请参阅。

显然,这是使示例正常工作所需要的

App.ApplicationController = Em.Controller.extend();
App.ApplicationView = Em.View.extend({
  templateName: 'application'
});

App.Router = Em.Router.extend({ 
  root: Em.Route.extend()
});

App.initialize();
App.ApplicationController = Em.Controller.extend();
App.ApplicationView = Em.View.extend({
  templateName: 'application'
});

App.Router = Em.Router.extend({ 
  root: Em.Route.extend()
});

App.initialize();
模板定义应该有一个名称

<script type="text/x-handlebars" data-template-name="application">
<script type="text/x-handlebars" data-template-name="application">


看。

嗯,我在这里没有发现任何错误。。。我怀疑这与title属性的绑定有关,它试图更新视图,但视图已被销毁,但不是100%确定。可以在github上发布问题并链接此问题吗?也许@kselden会给你一个答案。谢谢。我将在GitHub上创建一个问题:-)理想情况下,@Dan,回答这个问题,而不仅仅是编辑这个问题。