【问题标题】:EmberJS {{#with}} block not displayingEmberJS {{#with}} 块不显示
【发布时间】:2012-09-24 18:13:08
【问题描述】:

控制器看起来像这样

class App.ContactsController extends Tower.Controller
  index: (params) ->
    @set('person', App.HighrisePerson.create())
    @render "index"

视图看起来像这样

App.ContactsEditView = Ember.View.extend
  templateName: 'contacts/edit'
  resourceBinding: 'controller.person'
  init: (args...) ->
    @._super(args...)
    console.log(@.get('resource'))
    console.log('inited')

通过上面的块,我在控制台中看到资源设置为我的 Ember.Object 的实例

但使用以下视图代码

div class: "row-fluid", ->
  text "{{#with resource}}"
  text "Hello"
  text "{{/with}}"

父视图的相关部分

div class: "row-fluid contact-form", ->
  div class: "row-fluid", ->
    h1 "Want to work with us?"
    p "So...you want to be kohactivated!?!? Please take a few moments to fill out the form below and provide us with some details about your project, company or start-up."
  text "{{view App.ContactsEditView}}"

我没有看到 hello 的渲染输出

如果我将 hello 移到 #with 块之外,我会看到 hello,

所以我认为它由于某种原因无法识别资源

感谢任何帮助。

【问题讨论】:

    标签: ember.js towerjs


    【解决方案1】:

    没错——它在当前车把上下文而不是视图中寻找resource(我相信从 ember.js 0.9.8 开始,它不再是默认上下文)。你需要view.resource

    (旁注:相反,要从视图中引用车把上下文,请使用context.whatever

    【讨论】:

    • 糟糕,这似乎已经解决了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-02
    • 2013-08-11
    • 1970-01-01
    • 2012-05-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多