|
|
@ -382,6 +382,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
|
|
|
var TITLE = 'layui-select-title';
|
|
|
|
var TITLE = 'layui-select-title';
|
|
|
|
var NONE = 'layui-select-none';
|
|
|
|
var NONE = 'layui-select-none';
|
|
|
|
var CREATE_OPTION = 'layui-select-create-option';
|
|
|
|
var CREATE_OPTION = 'layui-select-create-option';
|
|
|
|
|
|
|
|
var PANEL_WRAP = 'layui-select-panel-wrap'
|
|
|
|
var PANEL_ELEM_DATA = 'layui-select-panel-elem-data';
|
|
|
|
var PANEL_ELEM_DATA = 'layui-select-panel-elem-data';
|
|
|
|
var selects = elem || elemForm.find('select');
|
|
|
|
var selects = elem || elemForm.find('select');
|
|
|
|
// 各种事件
|
|
|
|
// 各种事件
|
|
|
@ -410,6 +411,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
|
|
|
// 展开下拉
|
|
|
|
// 展开下拉
|
|
|
|
var showDown = function(){
|
|
|
|
var showDown = function(){
|
|
|
|
if(isAppendToBody){
|
|
|
|
if(isAppendToBody){
|
|
|
|
|
|
|
|
// 如果追加面板元素后出现滚动条,触发元素宽度可能会有变化,所以先追加面板元素
|
|
|
|
reElem.appendTo('body')
|
|
|
|
reElem.appendTo('body')
|
|
|
|
.show()
|
|
|
|
.show()
|
|
|
|
.css({width: title.width() + 'px'});
|
|
|
|
.css({width: title.width() + 'px'});
|
|
|
@ -770,9 +772,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
|
|
|
|
|
|
|
|
|
|
|
// 替代元素
|
|
|
|
// 替代元素
|
|
|
|
var reElem = $(['<div class="'+ (isSearch ? '' : 'layui-unselect ') + CLASS
|
|
|
|
var reElem = $(['<div class="'+ (isSearch ? '' : 'layui-unselect ') + CLASS
|
|
|
|
,(disabled ? ' layui-select-disabled' : '')
|
|
|
|
,(disabled ? ' layui-select-disabled' : '') + '"></div>'].join(''));
|
|
|
|
,(isCreatable ? ' layui-select-creatable' : '')
|
|
|
|
|
|
|
|
,(isAppendToBody ? ' layui-select-append-to-body' : '') + '"></div>'].join(''));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var triggerElem = $([
|
|
|
|
var triggerElem = $([
|
|
|
|
'<div class="'+ TITLE +'">'
|
|
|
|
'<div class="'+ TITLE +'">'
|
|
|
@ -806,14 +806,17 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
|
|
|
|
|
|
|
|
|
|
|
// 如果已经渲染,则Rerender
|
|
|
|
// 如果已经渲染,则Rerender
|
|
|
|
if(hasRender[0]){
|
|
|
|
if(hasRender[0]){
|
|
|
|
isAppendToBody && hasRender.data(PANEL_ELEM_DATA).remove();
|
|
|
|
if(isAppendToBody){
|
|
|
|
|
|
|
|
var panelWrapElem = hasRender.data(PANEL_ELEM_DATA);
|
|
|
|
|
|
|
|
panelWrapElem && panelWrapElem.remove();
|
|
|
|
|
|
|
|
}
|
|
|
|
hasRender.remove();
|
|
|
|
hasRender.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(isAppendToBody){
|
|
|
|
if(isAppendToBody){
|
|
|
|
reElem.append(triggerElem);
|
|
|
|
reElem.append(triggerElem);
|
|
|
|
othis.after(reElem);
|
|
|
|
othis.after(reElem);
|
|
|
|
var contentWrapElem = $('<div class="layui-form-select layui-select-panel"></div>').append(contentElem)
|
|
|
|
var contentWrapElem = $('<div class="'+ CLASS + ' ' + PANEL_WRAP +'"></div>').append(contentElem);
|
|
|
|
reElem.data(PANEL_ELEM_DATA, contentWrapElem) // 将面板元素对象记录在触发元素 data 中
|
|
|
|
reElem.data(PANEL_ELEM_DATA, contentWrapElem); // 将面板元素对象记录在触发元素 data 中
|
|
|
|
events.call(this, contentWrapElem, triggerElem, disabled, isSearch, isCreatable, isAppendToBody);
|
|
|
|
events.call(this, contentWrapElem, triggerElem, disabled, isSearch, isCreatable, isAppendToBody);
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
reElem.append(triggerElem).append(contentElem);
|
|
|
|
reElem.append(triggerElem).append(contentElem);
|
|
|
|