Home > Back-end >  Maximum Call stack Exceeded in jQuery Autocomplete
Maximum Call stack Exceeded in jQuery Autocomplete

Time:04-03

I'm facing the problem in jQuery autocomplete if I used focus() method inside my jQuery autocomplete then it throws maxim call stack exceeded and sometime I couldn't clear what I'm typed in the input type also. my code looks like

onSelect: function (output) {   
  $("#studentID").val(output.data);    
  $('#StudentName').focus(); 
},

If I comment the focus() method then there is no errors will happen, I have the validation of this field that validation only removed by focus() method

If I comment the focus() method then there is no errors will happen, I have the validation of this field that validation only removed by focus() method

Maximum call stack error could not be thrown thats my only concern

CodePudding user response:

Try this - never focus something that may trigger something on focus

onSelect: function (output) {   
  $("#studentID").val(output.data);    
  setTimeout(() => $('#StudentName').focus(),10); 
},
  • Related