2

I am using MagicSuggest for multiselect.In my form I am using tab to move to next field.When I press tab from one field,it should move to magicsuggest input field.For that i have given as

$("#mselect").focus(); //not working
$("#mselect input").focus(); //not working

This is my code.

 <link href="magicsuggest/magicsuggest.css" rel="stylesheet"> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

<script src="magicsuggest/magicsuggest.js"></script>
<script type='text/javascript'>
    var ms;
    $(document).ready(function () {

        function select() {
             ms = $('#ms-scrabble').magicSuggest({
                expandOnFocus: true,
                useTabKey: true,
                autoSelect: false,
                data: ['Banana', 'Apple', 'Orange', 'Lemon'],
                id:'sa'
            });     

                ms.setValue(['Banana']);    
        }          
 select();   

$("#test").blur(function(){
   test();      
});    
    });
    function test(){
    console.log(ms);
    ms.clear();
    ms.setValue(['Orange']);
    ms.collapse();
    $('#ms-scrabble').focus();
}
</script>
<form name='frm' method='post' action='test.php'>
<div><input class="form-control"></div>
<div><input class="form-control"></div>
<div><input class="form-control" id="ms-scrabble" name='ms-scrabble' autofocus="true"></div>
<div><input class="form-control" id="test"></div>
<input type='submit'>
</form>

Any help would be appreciated.

Regards, Rekha

rekha s
  • 577
  • 5
  • 7
  • 24

1 Answers1

3

I resolved the issue with the following code,

ms.input.focus();

Regards, Rekha

rekha s
  • 577
  • 5
  • 7
  • 24