mirror of https://github.com/layui/layui
优化 dropdown 初始化方法相关代码
parent
461ae352b8
commit
9c6a0a8182
|
@ -89,13 +89,13 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
|||
that.init(true);
|
||||
};
|
||||
|
||||
//初始化准备
|
||||
// 初始化准备
|
||||
Class.prototype.init = function(rerender){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,elem = options.elem = $(options.elem);
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
var elem = options.elem = $(options.elem);
|
||||
|
||||
//若 elem 非唯一
|
||||
// 若 elem 非唯一
|
||||
if(elem.length > 1){
|
||||
layui.each(elem, function(){
|
||||
dropdown.render($.extend({}, options, {
|
||||
|
@ -105,7 +105,7 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
|||
return that;
|
||||
}
|
||||
|
||||
//若重复执行 render,则视为 reload 处理
|
||||
// 若重复执行 render,则视为 reload 处理
|
||||
if(!rerender && elem[0] && elem.data(MOD_INDEX)){
|
||||
var newThat = thisModule.getThis(elem.data(MOD_INDEX));
|
||||
if(!newThat) return;
|
||||
|
@ -115,11 +115,11 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
|||
|
||||
// 初始化 id 属性 - 优先取 options > 元素 id > 自增索引
|
||||
options.id = 'id' in options ? options.id : (
|
||||
options.elem.attr('id') || that.index
|
||||
elem.attr('id') || that.index
|
||||
);
|
||||
|
||||
if(options.show) that.render(rerender); //初始即显示
|
||||
that.events(); //事件
|
||||
if(options.show) that.render(rerender); // 初始即显示
|
||||
that.events(); // 事件
|
||||
};
|
||||
|
||||
//渲染
|
||||
|
|
Loading…
Reference in New Issue