Ember.js - “不能对不在DOM中的Metamorph执行操作”造成模板 [英] Ember.js - "Cannot perform operations on a Metamorph that is not in the DOM" caused by template

查看:183
本文介绍了Ember.js - “不能对不在DOM中的Metamorph执行操作”造成模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 未捕获错误:无法执行操作不在DOM中的变形。我发现中的执行操作在-the-is-not-in-the-dom-in-ie8中,这些 两个的问题,这两个都涉及对DOM的直接操纵,不是在我的应用程序的情况。搜索错误消息还会返回与相同类型的直接DOM操作相关的许多Github问题。

解决方案

我失去了直到我发生在这个问题 Github从 search 与错误消息完全无关。



基本上,错误归结为一个Handlebars表达式包含在一个HTML注释中。



在代码中比在单词中更容易说,所以在这里sa jsFiddle有很多解释: http://jsfiddle.net/niaconis/JSj7W/1/



在模板中使用三个位置的 {{computedProp}} 表达式:正常情况下,在HTML注释中,以及在Handlebars块评论中。打开Web检查器,然后单击重新计算按钮查看产生的错误。



您可以从示例的模板中删除HTML注释,并查看代码将



希望这将引导其他丰富的Ember开发人员更容易地使用这样一个简单的解决方案。


I've been having an issue with Ember.js throwing the error:

Uncaught Error: Cannot perform operations on a Metamorph that is not in the DOM.

I found these two SO questions, both of which involve direct manipulation of the DOM, which is not the case in my app. Searching for the error message also returns numerous Github issues related to the same type of direct DOM manipulation.

解决方案

I was at a loss until I happened upon this issue on Github from a search entirely unrelated with the error message.

Basically, the error boils down to a Handlebars expression enclosed within an HTML comment.

It's probably easier said in code than in words, so here's a jsFiddle with lots of explanation baked in: http://jsfiddle.net/niaconis/JSj7W/1/

The {{computedProp}} expression is used three places within the template: as normal, within an HTML comment, and within a Handlebars block comment. Open up the web inspector and click the "Recompute" button to see the error produced.

You can remove the HTML comment from the example's template, and see that the code will run just fine when it is not present.

Hopefully, this will guide other blossoming Ember developers to such a simple solution more readily.

这篇关于Ember.js - “不能对不在DOM中的Metamorph执行操作”造成模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆