2

I am using MagicSuggest for multiselect textbox with dropdown.I don't know how to set values dynamically.I have tried

var ms =$('#fruits').magicSuggest({
    //placeholder: 'Type some real or fake fruits',
    //toggleOnClick: true,
    //selectFirst:true,
    expandOnFocus: true,
    useTabKey: true,
    autoSelect: false,
    data: ['Banana','Mango','Apple','Orange']
});
   ms.setValue(['Banana']);

The above code works fine.But I want to change the value dynamically based on other textbox value.I have tried,

var ms1=$('#fruits').magicSuggest({});
ms1.setValue(['banana']);  

$('#fruits').val(['Banana']);

var m=$('#fruits').magicSuggest({value:['Banana']});

These three solutions are not working.Please Help....

Regards, Rekha

Grushton94
  • 603
  • 1
  • 7
  • 17
rekha s
  • 577
  • 5
  • 7
  • 24

1 Answers1

2

try this

 ms.addToSelection('banana',false);
Suraj Singh
  • 4,041
  • 1
  • 21
  • 36
  • 2
    I made a miskate in the object creation .I globally declared the variable ms and then set the value using ms.setValue in another function and it worked. – rekha s Feb 28 '15 at 04:29