Iron Router で Meteor を使用していますが、typeahead (このバージョン: https://github.com/bassjobsen/Bootstrap-3-Typeahead ) が機能しないようです。
ここにいくつかのコードがあります:
HomeController = RouteController.extend({
//....
after: function () {
var tags = this.getData().tags;
console.log(tags);
if(tags.length > 0) {
var tags = ['hello', 'world'];
console.log("Adding typeahead for tags to ", $('.input-search')[0]);
console.log("tags: ", tags);
$('.input-search').typeahead({
source: tags,
updater: function(item) {
Router.go('/projects/tag/' + item);
}
});
}
},
アプリケーション レイアウトの一部であるヘッダーがあり、次のような入力があります。
<input type="text" class="form-control input-search" data-provide="typeahead" placeholder="Search">
after: 関数の jQuery は入力を正しく取得します。しかし、入力で typeahead を呼び出すと、typeahead が適切にアクティブ化されないようです。入力を入力しても、何も起こりません。
ただし、typeahead 呼び出しを setTimeout でラップすると、機能します。
もちろん、何かを setTimeouts でラップし始めるときはいつでも、何かが正しくありません。
Iron Router を使用する場合、先行入力を初期化する正しい場所はいつですか?