1

I am using the Twitter typeahead.js plugin. So to use it I am extend Ember's TextField. The plugin all works fine. Now I just want to make the value accessible inside the controller.

When I use the value binding inside the view class, it works fine. Here is the bin example. Here the value gets set initially and updates later. To test the text view type 'aaa'.

App.TypeAhead = Ember.TextField.extend({      
  classNames: ['cmp-typeahead'],    
  attributeBindings: ['id','value'],    
  valueBinding: 'targetObject.airportCode',
  ....
});

But when I try to set the value binding via the template, it doesn't seem to work. Here is the bin example. To test the text view type 'aaa'.

{{view App.TypeAhead data=airports valueBinding="view.targetObject.airportCode" 
       id="fromAirportCode"}}

What am I doing wrong?

blessanm86
  • 31,439
  • 14
  • 68
  • 79

1 Answers1

3

Since the view helper will keep the current controller, it's as simple as:

{{view App.TypeAhead data=airports valueBinding="airportCode" 
   id="fromAirportCode"}}

Example: http://emberjs.jsbin.com/ciwiv/1/edit

Bavo Van Geit
  • 855
  • 6
  • 15
  • Thanks this is working. But can I get the airportCode value directly in the view like this.get('airportCode'). Right now I need to use this.get('targetObject.airportCode'); My thought is if the view helper gets the controller, the class would also get it. – blessanm86 Apr 30 '14 at 23:31