ember.js - Typeahead and Ember.handelbars -


i trying implement typeahead elasticsearch backend. search seems working, trying tweak optic. use ember.handlebars helper wrote. first attempt using handelbars template engine:

app.searchcomponent = ember.textfield.extend({    didinsertelement: function() {     app.usersearchengine.initialize();     this.initializetypeahead();   },    initializetypeahead: function(){       var _this = this;       this.typeahead = this.$().typeahead({           hint: true,           highlight: true,           minlength: 3         },         {          name: _this.$().attr('id') || "typeahead",          // template: 'my: {{firstname}}',          limit: this.get("limit") || 5,          source: app.usersearchengine.ttadapter(),          templates:{             suggestion: ember.handlebars.compile('{{firstname}} {{lastname}}')          }         }       );   }  }); 

this giving me error:

uncaught typeerror: cannot read property 'container' of undefined caused ember in "_triagemustache" helper in line

 var helper = ember.handlebars.resolvehelper(options.data.view.container, property); 

this due fact try compile template directly.

if use handlebars.compile() instead of ember.handlebars.compile() work. seems context not correct.

you should use regular handlebars.compile here. typeahead library doesn't know ember bound templates, doesn't know how invoke them.

alternatively, template simple literal function, save hassle of shipping handlebars compiler in production or precompiling 1 specially:

templates: {   suggestion: function(context){ return context.firstname + ' ' + context.lastname; } } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -