我如何控制 Ember.js 附加呈现的应用程序模板的位置? [英] How do I control where Ember.js appends the rendered application template?

查看:16
本文介绍了我如何控制 Ember.js 附加呈现的应用程序模板的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的 Ember 应用程序切换为使用 Ember.Router,但是我遇到了应用程序模板附加位置的问题.当我调用 App.initialize() 时,它会在文档末尾呈现模板.有没有办法指定渲染的应用程序模板附加到哪里?

我的应用程序是一个 rails 应用程序,我正在尝试在我的一个页面上嵌入一个 Ember 应用程序.我不想更改当前页眉和页脚的呈现方式,因此理想情况下我可以指定 ember 呈现模板的位置.

这是一个 jsfiddle 示例.你可以看到它呈现:

<前>标题内容页脚内容测试 1测试 2测试 3

我想要的是:

<前>标题内容测试 1测试 2测试 3页脚内容

解决方案

设置 Ember.ApplicationrootElement 属性:http://jsfiddle.net/vAxkL/3/

文档:http://docs.emberjs.com/symbols/Ember.Application.html

EDIT -- 通过锚定到 1.0.pre 版本修复了小提琴:http://jsfiddle.net/vAxkL/11/

I'm trying to switch my Ember application over to using the Ember.Router but am having an issue with where the application template gets appended. When I call App.initialize() it renders the template at the end of the document. Is there a way to specify where the rendered application template gets appended to?

My application is a rails app and I'm trying to embed an Ember application on one of my pages. I don't want to change the way my current header and footer gets rendered so ideally I would be able to specify where ember renders the template.

Here is a jsfiddle example. You can see that it renders:

Header Content 
Footer Content 
Test 1 
Test 2 
Test 3

What I'm trying for is:

Header Content
Test 1
Test 2
Test 3
Footer Content

解决方案

Set the rootElement property of the Ember.Application: http://jsfiddle.net/vAxkL/3/

Doc: http://docs.emberjs.com/symbols/Ember.Application.html

EDIT -- Fixed the fiddle by anchoring to the 1.0.pre version: http://jsfiddle.net/vAxkL/11/

这篇关于我如何控制 Ember.js 附加呈现的应用程序模板的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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