Select2项按if子句显示

时间:2019-07-17 20:19:59

标签: javascript jquery-select2

我有一个关于select2的问题,当用户登录名仅显示id“ A”'文本或select2的用户登录将被锁定,而用户仅显示“ A”'文本时,但管理员登录项中显示select2'的所有项目(A和B文字),但我不知道该怎么办。

我的代码块:

var tahsilatData = [{
  id: "A",
  text: 'AÇIK TAHSİLAT'
}, {
  id: "B",
  text: 'SADECE BLOKE KREDİ KARTI İLE'
}];

$('#AcenteTahsilat').select2({
  placeholder: "Tahsilat Seçeneği",
  data: tahsilatData,
  minimumResultsForSearch: Infinity
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.7/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.7/js/select2.min.js"></script>

<div class="form-group m-form__group">
  <label for="AcenteTahsilat">Tahsilat Şekli :</label>
  <div id="AcenteTahsilatInfo" class="input-group m-input-group">
    <select class="form-control m-select2 m-select2-general w-100" id="AcenteTahsilat" name="AcenteTahsilat" style="width: 100%">
      <option></option>
    </select>
  </div>

0 个答案:

没有答案