W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
jQuery EasyUI提供了用于創(chuàng)建跨瀏覽器網(wǎng)頁的完整的組件集合,包括功能強大的datagrid(數(shù)據(jù)網(wǎng)格)、treegrid(樹形表格)、 panel(面板)、combo(下拉組合)等等,這些組件能夠組合使用,也可以單獨使用。
easyui的每個組件都有屬性、方法和事件。用戶可以很容易地對這些組件進行擴展。
屬性是定義在jQuery.fn.{plugin}.defaults。比如,dialog的屬性是定義在jQuery.fn.dialog.defaults上的。
事件(回調(diào)函數(shù))也是定義在jQuery.fn.{plugin}.defaults。
調(diào)用方法的語法:$('selector').plugin('method', parameter);
其中:
方法是定義在jQuery.fn.{plugin}.methods。每個方法有兩個參數(shù):jq和param。第一個參數(shù)'jq'是必需的,引用jQuery對象。第二個參數(shù)'param'引用方法傳遞的實際參數(shù)。比如,要擴展dialog組件的方法名為'mymove'的方法,代碼如下:
$.extend($.fn.dialog.methods, {
mymove: function(jq, newposition){
return jq.each(function(){
$(this).dialog('move', newposition);
});
}
});
現(xiàn)在您可以調(diào)用'mymove'方法來移動對話框(dialog)到指定的位置:
$('#dd').dialog('mymove', {
left: 200,
top: 100
});
下載庫,并在您的頁面中引用EasyUI CSS和JavaScript文件。
<link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
<script type="text/javascript" src="easyui/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
一旦您引用了EasyUI必要的文件,您就可以通過標記或者使用JavaScript來定義一個EasyUI組件。比如,要頂一個帶有可折疊功能的面板,您需要編寫如下HTML代碼:
<div id="p" class="easyui-panel" style="width:500px;height:200px;padding:10px;"
title="My Panel" iconCls="icon-save" collapsible="true">
The panel content
</div>
當通過標記創(chuàng)建組件,'data-options'屬性被用來支持自版本1.3以來HTML5兼容的屬性名稱。所以您可以如下重寫上面的代碼:
<div id="p" class="easyui-panel" style="width:500px;height:200px;padding:10px;"
title="My Panel" data-options="iconCls:'icon-save',collapsible:true">
The panel content
</div>
下面的代碼演示了如何創(chuàng)建一個綁定'onSelect'事件的組合框。
<input class="easyui-combobox" name="language"
data-options="
url:'combobox_data.json',
valueField:'id',
textField:'text',
panelHeight:'auto',
onSelect:function(record){
alert(record.text)
}">
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: