天天看點

Easyui筆記之動态添加元件

需求:頁面加載完成後,在操作的過程中動态增加需要的easyui元件。

關鍵操作:easyui解析器,$.parser.parse(context);

事例代碼:以combobox為例

var $td = $('<td></td>');
var combobox_str = '<select class="easyui-combobox" data-options="required: true,editable: false" style="width: 80px;">';
	combobox_str += '<option value="String">字元串</option>';
	combobox_str += '<option value="long">數字</option>';
	combobox_str += '<option value="boolean">布爾值</option>';
	combobox_str += '</select>';
var $combobox = $(combobox_str);
$td.append($combobox);
$tr.append($td);
$.parser.parse($tr);// 解析