. 나는 그것이 작동 될 때까지 모든 외부 영향을 제거하기 위해 베어 본 프로젝트를 만들었고, 그런 다음 그것을 프로젝트에 성공적으로 전송할 수있었습니다.
개념을 얻을 수 있음을 증명하고 프로젝트와 비교할 수있는 실습 예제로 사용할 수 있어야하는 내 기본 프로젝트입니다.
자신에게 html 파일을 생성하고이 붙여 넣습니다.
<!DOCTYPE html>
<html>
<head>
<title>TagsInput and TypeAhead TOGETHER!</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/bootstrap-tagsinput.css">
</head>
<body>
<h1>TagsInput and TypeAhead TOGETHER!</h1>
<select id="Country">
<option>UK Cars</option>
<option>German Cars</option>
</select>
<input type="text" id="carsSearch" placeholder="Type Car Names" />
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap-tagsinput.min.js"></script>
<script type="text/javascript" src="js/bootstrap3-typeahead.js"></script>
<script type="text/javascript" src="js/tagsinput and typeahead.js"></script>
</body>
</html>
을 JS 폴더와 파일이라고 tagsinput 및 typeahead.js을 만들고이 붙여 넣습니다.
$(document).ready(
function() {
// Call the data population
bindCarList();
}
);
bindCarList = function() {
// Call TagsInput on the input, and set the typeahead source to our data
$('#carsSearch').tagsinput({
typeahead: {
source: function() {
if ($('#Country').val() == "UK Cars") {
return ["Lotus", "TVR", "Jaguar", "Noble", "Land Rover", "Rover"];
} else {
return ["BMW", "Audi", "Volkswagen", "Mercedes-Benz"];
}
}
}
});
$('#carsSearch').on('itemAdded', function (event) {
// Hide the suggestions menu
$('.typeahead.dropdown-menu').css('display', 'none')
// Clear the typed text after a tag is added
$('.bootstrap-tagsinput > input').val("");
});
}
당신이 필요합니다 몇 가지 파일을 다운로드 할 수 있지만 가능하면 CDN을 사용하여 최소한으로 유지했습니다.
그건에서 https://github.com/timschlechter/bootstrap-tagsinput/tree/master/src
/js/bootstrap3-typeahead.js에서
/js/bootstrap-tagsinput.min.js 완벽하지는 않습니다. 태그를 추가하면 검색 텍스트를 지우고 목록을 숨기는 해결 방법을 사용해야했습니다. 입력에서 탭을 벗어날 수는 없지만 큰 것은 아닙니다. 그것은 꽤 좋지만 누군가가 그것을 향상시킬 수 있습니다.
출처
2015-08-06 15:42:55
Red
[Typeahead 플러그인 및 부트 스트랩 태그 입력 플러그인이 작동하지 않습니다.] (http://stackoverflow.com/questions/21641417/typeahead-plugin-and-bootstrap-tags-input-plugin-meteor-not-working) –