Accessing other controller from a view

a 夏天 提交于 2019-12-25 06:35:38

问题


i try to set a property of another controller via my click function.

  click: function(event){
    var controller =  this.get('controller');
    router.transitionTo('inc.index',this.content);
    console.log(controller.hidden)
    controller.set('hidden',false);
 }
})

Therefore i set up my tableController with a hiddenbinding:

App.TableController = Em.ArrayController.extend({
 needs: ['mainMenu'],
 hidden:true,
 hiddenBinding: 'controllers.mainMenu.isHidden'
 })
App.MainMenuController= Em.Controller.extend({
isHidden: true
})

In my navbar the attribute 'isHidden' should change when 'hidden' in the tableController changes.

<script type="text/x-handlebars" data-template-name="mainMenu">
  <nav>
    <ul class="nav">
      <li {{bindAttr class="isHidden:hidden"}}> {{#linkTo "incidents"}}   Störfall {{/linkTo}}</li>
    </ul>
    </nav>

Unfortunatly the binding doesn't work and i dont know why. I tried to do it the same way as it was posted here earlier on but i guess i understood something wrong.

来源:https://stackoverflow.com/questions/15642077/accessing-other-controller-from-a-view

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!