Reputation: 743
I am using Bootstrap and jQuery for same page. Previously i was using bootstrap typeahead for auto-completion but later decided to use jQuery autocomplete. But i am having problem with receiving the data autoselected. May be Its due to the confusion in the "$" sign as both jQuery and Bootstrap use same sign correct me if i am wrong. My code is
$('#startstop').autocomplete({
source: stopNames,
delay: 200,
minLength: 2,
onSelect:function (suggestion){
start = suggestion.value;
console.log(start);
}
});
the console shows object has no autocomplete method.
Upvotes: 0
Views: 219
Reputation: 10896
try something like this
include jquery Ui
<link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" media="screen" />
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$('#startstop').autocomplete({
source: stopNames,
delay: 200,
minLength: 2,
select:function ( event, ui){
start = this.value;
console.log(start);
}
});
</script>
Upvotes: 1
Reputation: 1890
If $
sign is the problem then use jQuery.noConflict() ,you can change the $ sign ofjQuery
.
JS:
jQuery.noConflict();
(function( $ ) {
$(function() {
// More code using $ as alias to jQuery
});
})(jQuery);
Upvotes: -1
Reputation: 2988
Its not a bootstrap problem first include jquery
and then jquery-ui
Upvotes: 1