10

ember 0.9.8.1 でエラーが発生します

You cannot use the same root element (body) multiple times in an Ember.Application 

これは何が起こっているのか分かりますか?どこを調べる必要があるかについての提案はありますか?

ありがとう。

4

1 に答える 1

13

DOM メンテナンスで競合するため、複数の Ember アプリケーションを同じ 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: '/'
        })
    })
});

ここでは、rootElementプロパティを使用して、アプリがバインドする DOM 要素を明示的に設定します。

デフォルトでは、Ember アプリは にバインドされるbodyため、2 回あると競合します...

例 @ http://jsfiddle.net/MikeAski/FMV8u/13/

于 2012-07-20T05:32:25.210 に答える