# Ember 1.0.0 breaks accessing controller from a view?

**URL:** <https://discuss.emberjs.com/t/ember-1-0-0-breaks-accessing-controller-from-a-view/2360>\
**Category:** Uncategorized\
**Created:** [September 2, 2013, 10:21am UTC](https://discuss.emberjs.com/t/ember-1-0-0-breaks-accessing-controller-from-a-view/2360 "2013-09-02T10:21:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![iest](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/iest/32/4694_2.png) [@iest](https://discuss.emberjs.com/u/iest)\
**Post date:** [September 2, 2013, 10:21am UTC](https://discuss.emberjs.com/t/ember-1-0-0-breaks-accessing-controller-from-a-view/2360/1 "2013-09-02T10:21:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![splattne](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/splattne/32/3694_2.png) [@splattne](https://discuss.emberjs.com/u/splattne)\
**Post date:** [September 2, 2013, 11:33am UTC](https://discuss.emberjs.com/t/ember-1-0-0-breaks-accessing-controller-from-a-view/2360/2 "2013-09-02T11:33:14Z")

</div>

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](http://stackoverflow.com/a/18571672/6461))

---

<div class="post-metadata">

**Author:** ![iest](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/iest/32/4694_2.png) [@iest](https://discuss.emberjs.com/u/iest)\
**Post date:** [September 2, 2013, 12:38pm UTC](https://discuss.emberjs.com/t/ember-1-0-0-breaks-accessing-controller-from-a-view/2360/3 "2013-09-02T12:38:40Z")

</div>

Thanks for your help! But I fixed it by swapping out `controller` for `targetObject` as I found in [this commit](https://github.com/emberjs/ember.js/commit/326af5a9c88df76f5effe11156a07b64c8b178a3#L3R412).

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

---

<div class="post-metadata">

**Author:** ![stefan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/stefan/32/14174_2.png) [@stefan](https://discuss.emberjs.com/u/stefan)\
**Post date:** [September 2, 2013, 11:30pm UTC](https://discuss.emberjs.com/t/ember-1-0-0-breaks-accessing-controller-from-a-view/2360/4 "2013-09-02T23:30:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![iest](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/iest/32/4694_2.png) [@iest](https://discuss.emberjs.com/u/iest)\
**Post date:** [September 3, 2013, 8:03am UTC](https://discuss.emberjs.com/t/ember-1-0-0-breaks-accessing-controller-from-a-view/2360/5 "2013-09-03T08:03:22Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![ggohierroy](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ggohierroy/32/10329_2.png) [@ggohierroy](https://discuss.emberjs.com/u/ggohierroy)\
**Post date:** [September 3, 2013, 3:50pm UTC](https://discuss.emberjs.com/t/ember-1-0-0-breaks-accessing-controller-from-a-view/2360/6 "2013-09-03T15:50:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![iest](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/iest/32/4694_2.png) [@iest](https://discuss.emberjs.com/u/iest)\
**Post date:** [September 3, 2013, 4:08pm UTC](https://discuss.emberjs.com/t/ember-1-0-0-breaks-accessing-controller-from-a-view/2360/7 "2013-09-03T16:08:24Z")

</div>

> [@ggohierroy](#):
>
> therefore they shouldn’t know about their controllers

Yeah I should really do a valueBinding inside the template…

> [@ggohierroy](#):
>
> I honestly have no idea why the change was not documented

**+1**
