/* * @Author: gk * layui.select 下拉选择框 * @Date: 2018-03-27 13:39:37 * @Last Modified by: gk * @Last Modified time: 2018-03-27 14:10:31 */ layui.define(['layer'], function (exports) { "use strict"; var select = { //填充数据 fillData: function ($select) { var dataurl = $select.attr('dataurl'); if (dataurl && $select[0].tagName == "SELECT") { $select.empty(); $.ajax({ type: 'get' , async: false , url: dataurl , dataType: 'json' , success: function (res) { if (res['state'] == 'OK') { var rows = res['obj']; layui.each(rows, function (index, item) { $select.append(""); }); //默认值吗? if ($select.val() == undefined) $select.val($select.attr('default')); } else { } } , error: function (e, m) { } }); } } } exports('select', select); });