ember.js - How to reference to emberJS controller from another view -


i'm using ember tools app. want add textfield trigger search in controller, in this example. controller , view:

productscontroller:

var productscontroller = ember.arraycontroller.extend({   search: function(query) {     console.log(query);   } });  module.exports = productscontroller; 

searchfieldview:

var searchfieldview = ember.textfield.extend({   insertnewline: function() {     var query = this.get('value');     app.productscontroller.search(query);   } }); module.exports = searchfieldview; 

but whenever textfield changing i've got error app.productscontroller has no method search. i've got feeling not 1 have created generated one.

you can use this.get('controller') current controller instance. or if u need controller instance can use this.get('controller').get('controllers.anothercontroller').. jsbin

hope helps.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -