Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 行动助手赢得';t在把手内工作';s{{{#if}_Javascript_Html_Button_Ember.js_Handlebars.js - Fatal编程技术网

Javascript 行动助手赢得';t在把手内工作';s{{{#if}

Javascript 行动助手赢得';t在把手内工作';s{{{#if},javascript,html,button,ember.js,handlebars.js,Javascript,Html,Button,Ember.js,Handlebars.js,我有一个machine\u list\u item.html模板,其中包含以下代码: {{#if view.machine.isGhost}} <div class="remove-machine-key-association"> <button {{action "aloha" target="view"}}></button> </div> {{/if}} 该按钮不会调用该函数,并会出现以下错误: 错误:断言失败:Mist.Mach

我有一个machine\u list\u item.html模板,其中包含以下代码:

{{#if view.machine.isGhost}}
<div class="remove-machine-key-association">
    <button {{action "aloha" target="view"}}></button>
</div>
{{/if}}
该按钮不会调用该函数,并会出现以下错误:

错误:断言失败:Mist.MachineListItemView上不存在操作“aloha”

但是,如果我注释掉handlebar的{{{if}}结构,代码就可以正常工作


任何帮助都将不胜感激

我想你在其他地方遇到了一个问题,这里有一个简单的例子说明它是如何正确工作的:

希望有帮助。

使用
{{{linkTo}}。。。{{/linkTo}
隐式创建视图。许多把手座都是这样做的。因此,
中引用
视图的任何内容实际上都引用了LinkToView

若要修复此问题,请使用
{{#with…as…}}
重命名视图,以使其不被遮挡

{{#with view as myView}}
  {{#linkTo 'machine' myView.machine}}
    {{#if myView.machine.isGhost}}
      <div class="remove-machine-key-association">
        <button {{action "aloha" target=myView}}></button>
      </div>
    {{/if}}
  {{/linkTo}}
{{/with}}
{{#视图为myView}
{{{#链接到'machine'myView.machine}
{{{如果myView.machine.isGhost}
{{/if}
{{/linkTo}
{{/与}}

有关更多详细信息,请参阅。

ember应用程序非常庞大。我只需要知道这个“其他地方”可能在哪里:)@GiwrgosTsopanoglou,你应该发布更多的代码,然后我猜:)这个项目由40多个文件组成,你愿意阅读所有这些代码吗P我正在编写的代码尚未提交,但所有相关文件都在那里。路径是src/mist/io/static/js/app@GiwrgosTsopanoglou我注意到在
app.js
中的路由中,当覆盖
exit
时,您没有调用
this.\u super()
。这可能会在您的视图中造成问题,因为这是余烬撕裂视图的地方。或者,您可以覆盖
停用
挂钩。
{{#with view as myView}}
  {{#linkTo 'machine' myView.machine}}
    {{#if myView.machine.isGhost}}
      <div class="remove-machine-key-association">
        <button {{action "aloha" target=myView}}></button>
      </div>
    {{/if}}
  {{/linkTo}}
{{/with}}