EmberJS - Manually bind controller to view

匿名 (未验证) 提交于 2019-12-03 01:00:01

问题:

Lately EmberJS changed a lot (Router, ...) and the code I have started to write less than a month ago is now broken. One of the issue I have right now is I am not able to manually bind the controller to the view.

I am using requireJS by the way...

So I used to the able to do something like this (here to define the view for my menu and the menu items), to actually get the Controller content and selected properties.

define (     'app/common/views/menu',     [         'text!app/common/templates/menu.hbs',         'ember'     ],     /**      * Menu view      *      * @param template      * @returns Class      */     function( template )     {         return Ember.View.extend         ({             controllerBinding : 'controller.controllers.menuController',             selectedBinding: 'controller.selected',             template: Ember.Handlebars.compile( template ),             NavItemView: Ember.View.extend             ({                 tagName: 'li',                 classNameBindings: 'isActive:active'.w(),                 isActive: function()                 {                     return this.get('item') === this.get('parentView.selected');                 }.property('item', 'parentView.selected').cacheable()             })         })     } ); 

It looks like 'controller.controllers.menuController' doesn't exists anymore. I have been able to find the class in the container cache 'container.cache.contoller:menu' but my view controller will still be null. I have also try App.MenuController being defined in the Application.create({})

Any idea?

On a side note, if anybody has a working example using the latest (github) EmberJS and requireJS I would be VERY interested :)

Cheers.

回答1:

Here is the latest TODOMVC Ember/require.js! :D I'll come back to answer your questions more explicitly:

https://github.com/sh4n3d4v15/ember-todos



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