How to get parent controller?


#1

Hi,

Here is my view/misc/textfield_on_keyup.coffee script

App.TextFieldOnKeyUp = Em.TextField.extend

keyUp: (e) ->
    console.log 'controller - ' + @get('controller')
And this is index.emblem inside templates/users/

= view App.TextFieldOnKeyUp valueBinding=“searchQuery” placeholder=“Search”

My question is, why am I not gettign the “UsersIndexController” in App.TextFieldOnKeyUp? Please help me ASAP

Thanks in advance.


#3

I think what you maybe looking for is parentView but I’m not 100% sure from your post how deeply nested your view is.


#4

Hi @varblob , yes, parentView. I’ve created new textbox with keyup event. But not getting the parent while trying to console.log the this.get(‘controller’) value.

I get

App.ApplicationView:ember1005

as a parentView, I need the name of view in which I’ve created this textbox.


#5

parentView.controller solved my problem. Thank you @varblob so much :clap: