I'm trying to attach a typeahead to a text input in one of my templates. Because Ember use's handlebars, jQuery's document ready function is not the place for the typeahead definition. Where is the proper place to put "template ready" code? I tried a controller but there was no response from the typeahead. I don't think the template was rendered yet.
App.PersonController = Ember.ObjectController.extend({
isEditing: false,
init: function(){
this._super();
$('.example-films .typeaheadcx').typeahead([{
name: 'best-picture-winners',
remote: 'http://twitter.github.io/typeahead.js/data/films/queries/%QUERY.json',
prefetch: 'http://twitter.github.io/typeahead.js/data/films/post_1960.json',
template: '<p><strong>{{value}}</strong> – {{year}}</p>',
engine: Ember.Handlebars
}]);
},
actions: {
edit: function() {
this.set('isEditing', true);
},
doneEditing: function() {
this.set('isEditing', false);
}
}
});