Question

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?

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top