我收到提示與Ember 0.9.8.1不能使用相同的根元素(體)多次在Ember.Application
You cannot use the same root element (body) multiple times in an Ember.Application
任何知道這是怎麼回事?我應該看看哪些建議?
謝謝。
我收到提示與Ember 0.9.8.1不能使用相同的根元素(體)多次在Ember.Application
You cannot use the same root element (body) multiple times in an Ember.Application
任何知道這是怎麼回事?我應該看看哪些建議?
謝謝。
您不能將幾個Ember應用程序綁定到相同的DOM元素,因爲它會爲DOM維護髮生衝突。
儘管如此,您仍然可以在同一頁面中實現幾個Ember應用程序。嘗試類似的東西:
App1 = Ember.Application.create({
rootElement: '#app1'
});
App1.ApplicationController = Ember.Controller.extend();
App1.ApplicationView = Ember.View.extend({
templateName: 'app1-view'
})
App1.Router = Ember.Router.extend({
root: Ember.Route.extend({
index: Ember.Route.extend({
path: '/'
})
})
});
App2 = Ember.Application.create({
rootElement: '#app2'
});
App2.ApplicationController = Ember.Controller.extend();
App2.ApplicationView = Ember.View.extend({
templateName: 'app2-view'
})
App2.Router = Ember.Router.extend({
root: Ember.Route.extend({
index: Ember.Route.extend({
path: '/'
})
})
});
在這裏,我們明確地設置到應用程序將綁定的DOM元素,使用rootElement
財產。
默認情況下,灰燼應用結合body
,所以如果你有兩次,他們衝突...
這消除了警告消息,但在您的小提琴中,App2.ApplicationView實際上並未加載。 – 2012-09-20 16:24:27
的確,我不再工作了。我看看那個。 Thx的信息。 – 2012-09-21 06:23:36
我剛剛填補了一個問題(https://github.com/emberjs/ember.js/issues/1395),因爲它看起來像一個迴歸。 – 2012-09-21 06:38:22
可以告訴你一些代碼? – Rajat 2012-07-20 05:10:55
看起來與http://stackoverflow.com/questions/8509076/ember-js-widgets – iX3 2012-09-27 20:18:19
有關,根據這個pull請求,「這意味着你正在創建多個Ember.Applications,而不指定不同的rootElement。默認的rootElement是body。」 https://github.com/emberjs/ember.js/issues/1192 – iX3 2012-09-27 20:20:38