Documentation

Each component of easyui has properties, methods and events. Users can extend them easily.

Properties

The properties is defined in jQuery.fn.{plugin}.defaults. For example, the dialog's properties is defined in jQuery.fn.dialog.defaults.

Events

The events(callback functions) is defined in jQuery.fn.{plugin}.defaults also.

Methods

The calling method syntax: $('selector').plugin('method', parameter);

Where:

The methods is defined in jQuery.fn.{plugin}.methods. Each method has two parameters: jq and param. The first parameter 'jq' is required, which refers to that jQuery object. The second parameter 'param' refers to the really parameter that pass through the method. For example, to extend a method named 'mymove' for the dialog component, the code looks like this:

  1. $.extend($.fn.dialog.methods, {  
  2.     mymove: function(jq, newposition){  
  3.         return jq.each(function(){  
  4.             $(this).dialog('move', newposition);  
  5.         });  
  6.     }  
  7. });  
  1. $.extend($.fn.dialog.methods, {  
  2.     mymove: function(jq, newposition){  
  3.         return jq.each(function(){  
  4.             $(this).dialog('move', newposition);  
  5.         });  
  6.     }  
  7. });  

Now you can call 'mymove' method to move the dialog to specified position:

  1. $('#dd').dialog('mymove', {  
  2.     left: 200,  
  3.     top: 100  
  4. });  
  1. $('#dd').dialog('mymove', {  
  2.     left: 200,  
  3.     top: 100  
  4. });  

Getting Started with jQuery EasyUI

Download the library and include EasyUI CSS and JavaScript files on your page.

  1. <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">  
  2. <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">  
  3. <script type="text/javascript" src="easyui/jquery-1.7.2.min.js"></script>  
  4. <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>  
  1. <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">  
  2. <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">  
  3. <script type="text/javascript" src="easyui/jquery-1.7.2.min.js"></script>  
  4. <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>  

Once you've included the EasyUI necessary files, you can define an EasyUI component from markup or using JavaScript. For example, to define a panel with collapsible functionality, you can write the HTML code like this:

  1. <div id="p" class="easyui-panel" style="width:500px;height:200px;padding:10px;"  
  2.         title="My Panel" iconCls="icon-save" collapsible="true">  
  3.     The panel content  
  4. </div>  
  1. <div id="p" class="easyui-panel" style="width:500px;height:200px;padding:10px;"  
  2.         title="My Panel" iconCls="icon-save" collapsible="true">  
  3.     The panel content  
  4. </div>  

When creating a component from markup, the 'data-options' attribute can be used to support HTML5 compliant attribute names since version 1.3. So you can rewrite the code above as:

  1. <div id="p" class="easyui-panel" style="width:500px;height:200px;padding:10px;"  
  2.         title="My Panel" data-options="iconCls:'icon-save',collapsible:true">  
  3.     The panel content  
  4. </div>  
  1. <div id="p" class="easyui-panel" style="width:500px;height:200px;padding:10px;"  
  2.         title="My Panel" data-options="iconCls:'icon-save',collapsible:true">  
  3.     The panel content  
  4. </div>  

The code below shows how to create a combobox that bind 'onSelect' event.

  1. <input class="easyui-combobox" name="language"  
  2.         data-options="  
  3.             url:'combobox_data.json',  
  4.             valueField:'id',  
  5.             textField:'text',  
  6.             panelHeight:'auto',  
  7.             onSelect:function(record){  
  8.                 alert(record.text)  
  9.             }" />  
  1. <input class="easyui-combobox" name="language"  
  2.         data-options="  
  3.             url:'combobox_data.json',  
  4.             valueField:'id',  
  5.             textField:'text',  
  6.             panelHeight:'auto',  
  7.             onSelect:function(record){  
  8.                 alert(record.text)  
  9.             }" />