Reputation: 1706
I have tried the way like this to reset select2 in my modal, but It does not work.
$(".payment-method").select2('data', null);
<div class="modal-body">
<form class="form-horizontal" id="category-form" enctype="multipart/form-data">
{{ csrf_field() }}
<div class="col-xs-12 col-sm-6 col-md-6">
<label>Payment Methods (Untuk kebutuhan tertentu)</label>
<div class="dropdown">
<select class="form-control payment-method" name="paymentType" multiple="multiple" data-placeholder="Select the payment method">
<option value="1">cash</option>
<option value="2">credit</option>
<option value="3">debit</option>
</select>
</div>
</div>
</div>
</form>
</div>
Upvotes: 1
Views: 5209
Reputation: 1706
$(".payment-method").val([]).trigger("change"); //Answered by apokryfos
Upvotes: 3
Reputation: 478
If you using Select2 4.x
just trigger change.select2
$('.payment-method').val(1).trigger('change.select2');
Upvotes: 0