Bootstrap Auto-complete Error: Cannot Read Property " " Of Undefined
Solution 1:
I Found my Error! I forgot to encapsulate my JQuery code inside the document ready event: $( document ).ready()
I COPED THIS EXPLANATION FROM SOME DOCS: Whenever you use jQuery to manipulate your web page, you wait until the document ready event has fired. The document ready event signals that the DOM of the page is now ready, so you can manipulate it without worrying that parts of the DOM has not yet been created. The document ready event fires before all images etc. are loaded, but after the whole DOM itself is ready.
A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you. Code included inside $( document ).ready() will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute.
Now My Code Works Fine after the following edit: (and you can use it in django) search.html
<script>
$(document).ready(function(){
$('.basicAutoComplete').autoComplete({
resolverSettings: {
url: '{% url "ajax_search" %}'
},
minLength: 1
});
});
</script>
Post a Comment for "Bootstrap Auto-complete Error: Cannot Read Property " " Of Undefined"