nikksan
nikksan

Reputation: 3471

Issue with jQuery Autocomplete used insideBootstrap Modal

I just encountered an issue with my project. Here it goes..I am trying to automatically trigger autocomplete with a value that the user has field in(so he doesnt have to do it again). My problem is that when this happens the user cannot use the Enter key OR the UP/DOWN arrow keys to select an option. Here is the fiddle.

$(function() {
//Show modal
$('#myModal').modal('show');

//Set autocomplete
$('#search' ).autocomplete({
      source: [
    "ActionScript",
    "Bootstrap",
    "C",
    "C++"
  ]
  });

 //Trigger autocomplete after some time
 setTimeout(function(){
   $('#search').val('c').trigger('keydown');
 }, 500);
});

Upvotes: 2

Views: 43

Answers (1)

Ankit Singh
Ankit Singh

Reputation: 1477

Just use this:

setTimeout(function(){
    $('#search').val('c').focus().trigger('keydown');
}, 500);

Upvotes: 2

Related Questions