php - Magicsuggest setValue() changes when move to other field -
on selectionchange setting new value when focus out setvalue change. here code : var ms=$('#mydiv').magicsuggest({ usecommakey: true, hidetrigger: true, placeholder: 'search here', allowduplicates: false, data: '/getdata.php', ajaxconfig: { xhrfields: { withcredentials: true, } }, valuefield: 'name', renderer: function(data){ return data.full_name; }, resultasstring: true }); $(ms).on('selectionchange', function(e, cb){ var response = cb.getvalue(); var respone_ary = response.tostring().split(','); if(respone_ary.length > 1){ this.removefromselection(cb.getselection()); this.setvalue(respone_ary); } }); for example : in response getting ...