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.
UPDATE: Fixed!
I swapped out this.get('controller')
for this.get('targetObject')
and it works as before. Had a peruse through a recent commit in ember source to find it...
Thanks for your suggestions guys!
this.get('controller')
gives you the implicilty createdTaggableInputController
and not the controller of your current route. But it's just a guess. - splattneEmber.TextField
used to extendView
. Unless otherwise specified, aView
'scontroller
defaults toparentView.controller
. As of Ember 1.0.0,Ember.TextField
extendsComponent
. AComponent
doesn't have a controller but rather has atargetObject
. Thats why your solution works! - Jim Halltext-input
component subclassing theEmber.TextField
one, and aselect-input
component that subclasses theEmber.Select
class. However, in theselect-input
code I was able to access the controller withthis.get('controller')
, and in thetext-input
I needed to resort to the solution suggested in the UPDATE section above (this.get('targetObject')
). I just wanted to comment about it here because it seems intereseting, and perhaps someone has some insight on the reasons for this. - Ernesto