Home » Jquery » javascript – Error accessing jQuery Autocomplete in Angular controller on document ready

javascript – Error accessing jQuery Autocomplete in Angular controller on document ready

Posted by: admin February 22, 2020 Leave a comment

Questions:

In a div with Angular controller, there’s an autocomplete that I’m trying to disable on document ready:

<div class="row" ng-controller="myController">
  <!-- autocomplete -->
</div>
$(document).ready(function() {
  $('#AutocompleteId').autocompletesearch('disable');
});

When I try to render the page, an error occurs:

Error: cannot call methods on autocompletesearch prior to initialization; attempted to call method ‘disable’

It seems like the autocomplete initialization is not ended when I’m trying to access to it.

How to&Answer: