Ember 1.0.0 breaks accessing controller from a view?

I’m using a render helper inside a template, which renders a searchbox with a typeahead.

Essentially (code removed for brevity):

script(type='text/x-handlebars', data-template-name='index')
    {{render search}}

script(type='text/x-handlebars', data-template-name='search')
    {{view App.TaggableInput valueBinding="searchText"}}

Which gives me a SearchController separated from the IndexController.

Inside App.TaggableInput I’m grabbing searchController to do some checking on the keyUp event:

App.TaggableInput = Ember.TextField.extend({
    keyUp: function(e){
        var controller = this.get('controller');
        // Do stuff with the controller

On Ember RC7, I can access the controller inside theview as you’d expect with this.get('controller').get('searchText').

However in Ember 1.0.0 this.get('controller') returns the view, and whatever I do I can’t get searchController.

I can’t find any related info on the ember website regarding what’s changed or what I’m supposed to do… for now I’m sticking with RC7.

Any ideas? I’ve spent hours on it this morning and can’t figure it out… Thanks.


Try to use this line instead to access the route’s controller:

var controller = this.get('parentView.controller');

(longer answer here on your StackOverflow post)

Thanks for your help! But I fixed it by swapping out controller for targetObject as I found in this commit.

Seems they’ve changed textField and textArea into components instead of views… so can’t access the explicit controller anymore? I dunno.

ideally you should bubble an action up the hierarchy. This allows for some nice lose coupling. Reaching up the hierarchy manually is essentially instant technical debt.


This was going to be a component that I was going to use in multiple places, so I wanted to keep as much functionality inside the view… However if I was going to do it again, I’d move most of the logic into the controller.

Regardless, using this.controller inside textField did work before 1.0.0, and now it doesn’t. I kind of expected a little documentation on a breaking change like that…

I had the same problem and I tried solving the issue for an excessive amount of time. If I had known that the text field was now a component instead of a view, it would’ve saved me a lot of time. I honestly have no idea why the change was not documented…

That being said, what I know is that components are supposed to be isolated, therefore they shouldn’t know about their controllers. Basically, you shouldn’t be able to do something like this.('controller').doSomething().

You can definitely do all of your logic inside the component, but as soon as you need to communicate with the rest of the application, you do so with the sendAction method.


Yeah I should really do a valueBinding inside the template…