Clear select2 without triggering change event

前端 未结 2 465
甜味超标
甜味超标 2020-12-30 04:57

I have a select2 input that I\'m using and on \'change\' I\'m grabbing the values and performing an action. I\'m trying to clear that select2 without triggering a change eve

相关标签:
2条回答
  • 2020-12-30 05:49

    You can use the following with Select2 4.x

    $docInput.val(null).trigger('change.select2');
    
    0 讨论(0)
  • 2020-12-30 05:54

    I believe all you need is:

    $docInput.select2('data', null, false);

    0 讨论(0)
提交回复
热议问题