James Riady James Riady - 3 years ago 248
jQuery Question

JQuery reset select2 in modal

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>


Answer Source
$(".payment-method").val([]).trigger("change"); //Answered by apokryfos
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download