本文介绍了emberjs将body或id添加到body标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读这个关于如何添加标签与类到视图ie ::

I have read this SO post on how to add tags with a class to a view i.e. ::

App.ApplicationView = Ember.View.extend
  name: 'Home',
  layoutName: 'layouts/application',
  templateName: 'views/home'
  tagName: 'div'
  elementId: 'home'

然而,有没有办法调整应用程序设置ie ::

However, is there a way to adjust the application setup i.e. ::

window.App = Ember.Application.create
    Store: DS.Store.extend
        revision: 10,
        adapter: DS.fixtureAdapter

要配置类或id附加到身体标签?

To configure a "class" or "id" attached to the body tag?

当前Ember设置:

DEBUG: ------------------------------- 
DEBUG: Ember      : 1.5.1 ember.js?body=1:3522
DEBUG: Handlebars : 1.3.0 ember.js?body=1:3522
DEBUG: jQuery     : 2.1.1 ember.js?body=1:3522
DEBUG: ------------------------------- 

当前源视图:

<body class="ember-application" data-ember-extension="1">
<div id="home" class="ember-view">
<h1>Ember Layout</h1>
<h1>Home View</h1>
</div>
</body>

我将注意到我正在使用emblemjs作为我的手柄模板,并且在应用程序布局中设置正文。

I will note I am using emblemjs for my handlebars templates and the body is setup in the application layout.

推荐答案

阅读和,我用这个解决方案:

After reading add-css-classes-to-body-in-ember-js and jquery attr id, I went with this solution:

App.ApplicationRoute = Ember.Route.extend
  activate: ->
    this._super();
    document.title = Ember.get('App.var_page_default_title')
    $('body').attr id: 'view_home'

这篇关于emberjs将body或id添加到body标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 21:11