在指南中我可以找到:
"如果要将Ember应用程序嵌入到现有站点中,则可以通过提供rootElement属性为特定元素设置事件侦听器:
window.App = Ember.Application.create({
rootElement: '#sidebar'
});
Run Code Online (Sandbox Code Playgroud)
"
请举例说明如何正确使用它.
Mik*_*ski 24
HTML
<script type="text/x-handlebars" data-template-name="app-view">
My ember app view
</script>
This is a static content
<div id="app-container"></div>
This is a static content
Run Code Online (Sandbox Code Playgroud)
JS
App = Ember.Application.create({
rootElement: '#app-container'
});
App.ApplicationController = Ember.Controller.extend();
App.ApplicationView = Ember.View.extend({
templateName: 'app-view'
});
App.Router = Ember.Router.extend({
root: Ember.Route.extend({
index: Ember.Route.extend({
route: '/',
connectOutlets: function (router) {
// do some stuff here...
}
})
})
});
App.initialize();
Run Code Online (Sandbox Code Playgroud)
这是JSFiddle:http://jsfiddle.net/MikeAski/xtzNB/
| 归档时间: |
|
| 查看次数: |
3440 次 |
| 最近记录: |