Javascript 当与ember js一起使用时,如何为typeahead指定预编译模板?

Javascript 当与ember js一起使用时,如何为typeahead指定预编译模板?,javascript,ember.js,handlebars.js,typeahead.js,Javascript,Ember.js,Handlebars.js,Typeahead.js,我正在使用typeahead js和Ember。当我初始化typeahead时,我可以使用handlebar.compile指定一个自定义模板,但为此,我必须包含handlebar的完整版本,而不仅仅是运行时。这显然不是一个理想的结果。 如果我尝试在下面的代码中包含预编译模板,我会得到 未捕获的TypeError:无法调用未定义的方法“push” 错误。 这是我的密码- $("input[name='myTypeAhead']").typeahead("destroy").typeahead({

我正在使用typeahead js和Ember。当我初始化typeahead时,我可以使用handlebar.compile指定一个自定义模板,但为此,我必须包含handlebar的完整版本,而不仅仅是运行时。这显然不是一个理想的结果。 如果我尝试在下面的代码中包含预编译模板,我会得到

未捕获的TypeError:无法调用未定义的方法“push”

错误。 这是我的密码-

$("input[name='myTypeAhead']").typeahead("destroy").typeahead({
        hint: true,
        highlight: true
  },
  {
        name: "prerequisites",
        displayKey: "val",
        source: this.bhObject.ttAdapter(),
        templates: {
              suggestion: Ember.TEMPLATES["suggestions"]
              // suggestion: Handlebars.compile("<p><strong>{{val}}</strong></p>")
        }

   });
有人能建议一下正确的方法吗?
谢谢

我不是百分之百这么认为,但我认为这是因为安博对车把进行了改动。余烬添加功能,以手柄,使其更适合余烬模板。因此,正常车把输出不同于余烬车把输出。我的建议是不要使用Ember预编译器,而只使用普通的Handlebar预编译器。

您可能在Handlebar运行时之前加载模板文件…@CodeJack如果他这样做,当Ember模板尝试调用
Ember.handelbar.template()
时,就会抛出一个错误。
<p><strong>{{val}}</strong></p>
Uncaught TypeError: Cannot call method 'push' of undefined suggestions.js:9
anonymous suggestions.js:9
(anonymous function) handlebars.js:436
getSuggestionNode typeahead.bundle.js:1116
jQuery.extend.map jquery.js:686
getSuggestionsHtml typeahead.bundle.js:1107
render typeahead.bundle.js:1095
renderIfQueryIsSame typeahead.bundle.js:1146
get typeahead.bundle.js:619
proxy jquery.js:731
update typeahead.bundle.js:1144
updateDataset typeahead.bundle.js:1314
reverseArgs typeahead.bundle.js:34
jQuery.extend.each jquery.js:590
_.each typeahead.bundle.js:32
update typeahead.bundle.js:1312
onQueryChanged typeahead.bundle.js:1461
flush typeahead.bundle.js:792
trigger typeahead.bundle.js:783
checkInputValue typeahead.bundle.js:968
onInput typeahead.bundle.js:929
proxy jquery.js:731
jQuery.event.dispatch jquery.js:4676
elemData.handle jquery.js:4361