는, 필터링이 마크 업에 따라 정확하지 않았다. 입력 유형에 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>
당신이 사용하는 어떤 브라우저? 그것은 나를 위해 크롬에서 작동합니다 – Siavas
나도 나를 위해 태그가로드시 나타나지 않는다 – user596502
프로젝트에서 'input # expertise' 사이의 공백을 제거하십시오. 공백을 남기면 #expertise가 자식임을 의미합니다. 귀하의 경우에는 #expertise가 입력의 ID이므로 selector는 'input # expertise'입니다. – Siavas