0

This AngularJs function works only when the page loads for the first time and when I refresh it will work and when I go to other page and come back to this page it will not work. I need this function to work even when I visit back from other pages. Is there any alternative?

angular.element(document).ready(function () {
    $("#SearchBox1").autocomplete('/api/search/predicateNames', {
        formType: "POST",
        dataType: "json",
        scroll: false,
        matchSubset: false,
        width: 300,
        max: 10,
        selectFirst: false,
        cacheLength: 1,
        formatItem: formatResultItem,
        parse: parseResultData,
        selectedRearch: selectedRearchForMobile
    });
});
Mustafa Poya
  • 2,615
  • 5
  • 22
  • 36
  • 1
    Don't bind autocomplete on #SearchBox1 element when document ready, but when your page controller loads. When you switch back and forward between pages probably new #SearchBox1 is created, that does not have this autocomplete binding set up. – AvgustinTomsic Oct 11 '22 at 11:31

0 Answers0