@Siavasが述べたように、フィルタリングは、あなたのマークアップどおり正しくありませんでした。入力の型がそのidを持っていたので$( 'input #expertise')を$( '#expertise')に変更しました。
tagsInputの初期化を忘れたため、この例は機能しませんでした。これらのgit-hubの例を参考にして、このスニペットを確認してください。
var citynames = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: {
url: 'https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/assets/citynames.json',
filter: function (list) {
return $.map(list, function (cityname) {
return { name: cityname };
});
}
}
});
citynames.initialize();
$('input').tagsinput({
typeaheadjs: {
name: 'citynames',
displayKey: 'name',
valueKey: 'name',
source: citynames.ttAdapter()
}
});
<link href="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.8.0/bootstrap-tagsinput.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap-theme.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="form-group">
<label class="col-lg-3 control-label">Expertise</label>
<div class="col-lg-5">
<input type="text" name="cities" id="expertise" class="form-control" />
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Interests</label>
<div class="col-lg-5">
<input type="text" name="cities1" id="interests" class="form-control" value="" data-role="tagsinput" />
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.8.0/bootstrap-tagsinput.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.11.1/typeahead.bundle.min.js"></script>
あなたはどのようなブラウザを使用していますか?それは私のChromeのために働く – Siavas
私もあまりにも私のためにタグはロード時に表示されません – user596502
あなたのプロジェクトでは、 'input#expertise'の間からスペースを取り除いてみてください - スペースを残すとき、#expertiseが子であることを意味しますあなたのケースでは#expertiseは入力のIDなので、セレクタは 'input#expertise'です。 – Siavas