Select2 plugin "set" method after "update" not working as expected (solution included)
Select2 plugin "set" method after "update" not working as expected (solution included)
When we update Select2 field with JSON
editor.field('select2_field').update(json);
and we set the value
editor.field('select2_field').set(value);
The value is not shown in the field in the editor (it is only set). If we would like the value to be shown we must extend the method "set" in the Select2 plugin
set: function ( conf, val ) {
conf._input.val( val );
}
to
set: function ( conf, val ) {
conf._input.val( val ).trigger('change');
}
according to discussion http://stackoverflow.com/questions/19639951/how-do-i-change-selected-value-of-select2-dropdown-with-jqgrid
I have tested this in Select2 4.0.1 and 4.0.2. I hope you will include this into the next Select2 plugin update.
This discussion has been closed.
Replies
cheeers mate! that was what i was looking for.
Hi,
Thanks for letting me know about this and sorry for my delay in replying! It will indeed be in the next plug-in update.
Regards,
Allan