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?

4

1 回答 1

3

由于视图助手将保留当前控制器,因此很简单:

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

示例:http ://emberjs.jsbin.com/ciwiv/1/edit

于 2014-04-30T16:20:17.133 回答