由于我使用脚本进行自动完成输入,问题是其中一个工作而另一个不起作用,所以我该如何解决这个问题呢?
<input class="ventypeahead form-control" type="text" placeholder="category">
<script type="text/javascript">
var path = "{{ route('autocompletecategory') }}";
$('input.cattypeahead').typeahead({
source: function (query, process) {
return $.get(path, { query: query }, function (data) {
return process(data);
});
}
});
</script>
<input class="cattypeahead form-control" type="text" >
<script type="text/javascript">
var path = "{{ route('autocompletevendor') }}";
$('input.ventypeahead').typeahead({
source: function (query, process) {
return $.get(path, { query: query }, function (data) {
return process(data);
});
}
});
</script>
答案 0 :(得分:0)
问题是使用var path
两次wrong class in wrong place
或using input in wrong place
,
只需撤消班级名称,也可以更改变量名称,
<input class="ventypeahead form-control" type="text" placeholder="category">
<script type="text/javascript">
var path1 = "{{ route('autocompletecategory') }}";
$('input.ventypeahead').typeahead({
source: function (query, process) {
return $.get(path1, { query: query }, function (data) {
return process(data);
});
}
});
</script>
<input class="cattypeahead form-control" type="text" >
<script type="text/javascript">
var path2 = "{{ route('autocompletevendor') }}";
$('input.cattypeahead').typeahead({
source: function (query, process) {
return $.get(path2, { query: query }, function (data) {
return process(data);
});
}
});
</script>