0
有一个简单的ember.js应用程序,其中一个视图显示在网页的特定位置。看看这个的jsfiddle:http://jsfiddle.net/jkkK3/9/Ember模板显示两次
App = Ember.Application.create({
ready: function(){
this._super();
this.ApplicationView.create().appendTo(".content");
},
ApplicationController: Ember.Controller.extend({
}),
ApplicationView: Ember.View.extend({
templateName: 'application'
}),
Router: Ember.Router.extend({
root: Ember.Route.extend({
})
})
});
我的问题是:为什么“这里的一些内容”的元素显示两次?它在我移除路由器时起作用,但这正是我无法做到的,因为我尝试将路由器添加到我的Ember应用程序中。您能否帮我在红色框内显示一次应用程序视图?
的使用rootElement的财产是的,你是对的。那么我怎么才能显示它一次,将它追加到“.content”div? – 2012-07-25 16:08:47
你不需要在ready()方法中追加它 – zaplitny 2012-07-25 16:10:55
然后它被放置在body元素中。我需要把它放在特定的元素中,在我的例子中是“.content”。 – 2012-07-25 16:11:50