暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

forms-selects.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * Selects & Tags
  3. */
  4. 'use strict';
  5. $(function () {
  6. const selectPicker = $('.selectpicker'),
  7. select2 = $('.select2'),
  8. select2Icons = $('.select2-icons');
  9. // Bootstrap Select
  10. // --------------------------------------------------------------------
  11. if (selectPicker.length) {
  12. selectPicker.selectpicker();
  13. }
  14. // Select2
  15. // --------------------------------------------------------------------
  16. // Default
  17. if (select2.length) {
  18. select2.each(function () {
  19. var $this = $(this);
  20. $this.wrap('<div class="position-relative"></div>').select2({
  21. placeholder: 'Select value',
  22. dropdownParent: $this.parent()
  23. });
  24. });
  25. }
  26. // Select2 Icons
  27. if (select2Icons.length) {
  28. // custom template to render icons
  29. function renderIcons(option) {
  30. if (!option.id) {
  31. return option.text;
  32. }
  33. var $icon = "<i class='" + $(option.element).data('icon') + " me-2'></i>" + option.text;
  34. return $icon;
  35. }
  36. select2Icons.wrap('<div class="position-relative"></div>').select2({
  37. dropdownParent: select2Icons.parent(),
  38. templateResult: renderIcons,
  39. templateSelection: renderIcons,
  40. escapeMarkup: function (es) {
  41. return es;
  42. }
  43. });
  44. }
  45. });