How do I clear select2 items when using datatables?
Note: I MUST use version 3.5.4.
$(’.select2’).val(null).trigger(‘change’);
and a ton more things I tried do not work
Here’s a fiddle:
How do I clear select2 items when using datatables?
Note: I MUST use version 3.5.4.
$(’.select2’).val(null).trigger(‘change’);
and a ton more things I tried do not work
Here’s a fiddle:
The reason your code doesn’t work is that your <input>
s that you’re wrapping with Select2 widgets don’t have the “select2” class, but the code you’re using to reset them is looking for all elements with that class. Add that class to your <input>
elements and your code will work just fine.