0

所以我混合了一些视图可访问的方法和一些私有的方法......

# mixin.coffee
App.LinkParsing = Em.Mixin.create
  method1: ->
    alert "foo"

  actions:
    method2: (link) ->
      alert "too #{link}"

    method3: (link) ->
      @method2(link)
      # and some other stuff...

方法 2 和 3 在actions对象中,因此可以在视图中访问它们。

# view.handlebars
<a {{bindAttr href="url"}}{{action method3 this}}>foo</a>

我需要在点击时访问方法 3,但它可以访问方法 2。

问题是,在method3里面,我得到了

undefined 不是函数:this.method2

4

1 回答 1

1

您可以使用sendactions哈希中调用函数。

this.send('method2',link);
于 2013-09-21T05:45:28.900 回答