Learning Essentials:
1. Loading mode
2. List of properties
3. Event List
4. Method List
This section focuses on how to use the draggable (drag) component in Easyui, which is not dependent on other components.
A Load mode
Class load mode This way looks like HTML code is not clean and can pollute HTML. It is recommended to use JS method to load
<!DOCTYPE HTML><HTML><Head><title>JQuery Easy UI</title><MetaCharSet= "UTF-8" /><Scripttype= "Text/javascript"src= "Easyui/jquery.min.js"></Script><Scripttype= "Text/javascript"src= "Easyui/jquery.easyui.min.js"></Script><Scripttype= "Text/javascript"src= "Easyui/locale/easyui-lang-zh_cn.js" ></Script><Scripttype= "Text/javascript"src= "Js/index.js"></Script><Linkrel= "stylesheet"type= "Text/css"href= "Easyui/themes/default/easyui.css" /><Linkrel= "stylesheet"type= "Text/css"href= "Easyui/themes/icon.css" /></Head><Body><DivID= "box"style= "Width:400px;height:200px;background:orange;"> </Div></Body></HTML>
JS Load Call
// JS Load Call $ (' #box '). draggable ();
Two Property List
Draggable Property
Property Name Value Description
Proxy null/string, function when using ' clone ', clone an alternative element to drag. If you specify a function, the override element is customized.
Revert False/boolean is set to True, the start position is returned when dragging is stopped
The CSS pointer style when cursor move/string is dragged
DeltaX Null/number The dragged element corresponds to the current cursor position x
DeltaY Null/number The dragged element corresponds to the current cursor position y
Handle Null/selector start dragging the handle
Disabled False/boolean is set to true to stop dragging
The width of the container in which edge 0/number can be dragged
Axis null/string Setting Drag to Vertical ' V ', or horizontal ' h '
JS Code
$ (' #box '). draggable ({revert:true, cursor:' Text ', handle:' #pox ', Disabled:true, Edge:180, Axis:' V ', Proxy:' Clone ', DeltaX:50, DeltaY:50, Proxy:function(source) {varp = $ (' <div style= "width:400px;height:200px;border:1px dashed #ccc" > "); p.html (source). HTML ()). AppendTo (' Body '); returnp; } });
Iii. List of events
Event name in-pass & nbsp Description
Onbeforedrag e &NBS P Drag before triggering, return false to cancel dragging
Onstartdrag &N Bsp e Drag start trigger
Ondrag ; e &N Bsp trigger during drag, cannot be dragged returns false
Onstopdrag e & nbsp Drag-stop trigger
$ (' #box 'function (e) { alert (' trigger before dragging!) '); return false function (e) { alert (' trigger when dragging! 'function (e) { alert (' triggers ' during drag! 'function (e) { alert (' triggers when dragging stops! ');},});
Four Method List
Event Name parameter description
Options None Return Property object
Proxy None returns the drag proxy element if the Proxy property is set
Enable none to allow dragging
Disable none Prohibit dragging
$ (' #box '). Draggable (' disable '); $ (' #box '). Draggable (' Enable '); Console.log ($ (' #box '). draggable (' options '));
The above method is directly after the element binding draggable directly into the relevant parameters can be
JQuery Easyui---draggable (drag) component