diff --git a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js index 4ae2b817..2b3d9e7a 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js +++ b/src/admin/Bootstrap.Admin/wwwroot/lib/longbow-select/longbow-select.js @@ -75,7 +75,7 @@ // 新控件
this.$ctl = $(lgbSelect.Template).insertBefore(this.$element); if ($input.attr('data-toggle') === 'lgbSelect') { - this.$input = $input.addClass("form-select-input").attr("aria-haspopup", "true").attr("aria-expanded", "false").attr("data-toggle", "dropdown"); + this.$input = $input.addClass("form-select-input").attr("aria-haspopup", "true").attr("aria-expanded", "false").attr("data-toggle", "dropdown").attr("readonly", true); } else { this.$input = $(''); diff --git a/src/client/Bootstrap.Client/wwwroot/lib/longbow-select/longbow-select.css b/src/client/Bootstrap.Client/wwwroot/lib/longbow-select/longbow-select.css index 6ea594a0..ffdb1968 100644 --- a/src/client/Bootstrap.Client/wwwroot/lib/longbow-select/longbow-select.css +++ b/src/client/Bootstrap.Client/wwwroot/lib/longbow-select/longbow-select.css @@ -50,6 +50,10 @@ cursor: not-allowed; } +.form-select.is-disabled .form-select-append { + color: #c0c4cc; +} + .form-select-input { color: #606266; outline: none; diff --git a/src/client/Bootstrap.Client/wwwroot/lib/longbow-select/longbow-select.js b/src/client/Bootstrap.Client/wwwroot/lib/longbow-select/longbow-select.js index 6001c350..2b3d9e7a 100644 --- a/src/client/Bootstrap.Client/wwwroot/lib/longbow-select/longbow-select.js +++ b/src/client/Bootstrap.Client/wwwroot/lib/longbow-select/longbow-select.js @@ -75,7 +75,7 @@ // 新控件
this.$ctl = $(lgbSelect.Template).insertBefore(this.$element); if ($input.attr('data-toggle') === 'lgbSelect') { - this.$input = $input.addClass("form-select-input").attr("aria-haspopup", "true").attr("aria-expanded", "false").attr("data-toggle", "dropdown"); + this.$input = $input.addClass("form-select-input").attr("aria-haspopup", "true").attr("aria-expanded", "false").attr("data-toggle", "dropdown").attr("readonly", true); } else { this.$input = $(''); @@ -114,11 +114,17 @@ // save attributes var attrs = []; - ["id", "data-default-val"].forEach(function (v, index) { + ["id", "name", "class", "data-valid", "data-default-val"].forEach(function (v, index) { var value = that.$element.attr(v); if (value !== undefined) attrs.push({ name: v, value: value }); }); + var disabled = this.$element.prop('disabled'); + // set disabled property + if (disabled) { + this.disabled(); + } + // replace element select -> input hidden this.$element.remove(); this.$element = $('').val(that.val()).insertBefore(this.$input); @@ -139,12 +145,15 @@ this.$input.removeAttr('disabled'); }; - _proto.reset = function (value) { + _proto.reset = function (value, init) { var that = this; // keep old value var oldValue = this.$input.attr('value'); + // default select value + if (init == undefined) init = true; + // warning: must use attr('value') method instead of val(). otherwise the others input html element will filled by first element value. // see https://gitee.com/LongbowEnterprise/longbow-select/issues/IZ3BR?from=project-issue this.$input.attr('value', '').removeClass('is-valid is-invalid'); @@ -153,10 +162,12 @@ $.each(value, function (index) { var $item = $('' + this.text + ''); that.$menus.append($item); - if (this.selected === true || this.value === oldValue || index === 0 || this.value === that.$element.attr('data-default-val')) { - that.$input.attr('value', this.text); - that.$element.val(this.value).attr('data-text', this.text); - $activeItem = $item; + if (init) { + if (this.selected === true || this.value === oldValue || index === 0 || this.value === that.$element.attr('data-default-val')) { + that.$input.attr('value', this.text); + that.$element.val(this.value).attr('data-text', this.text); + $activeItem = $item; + } } }); if ($activeItem !== null) $activeItem.addClass('active');