JQuery Easy UI Draggable (drag) Component
As mentioned above, jQuery EasyUI plug-in references are usually used in two ways (excluding the easyload Loading Method). Therefore, the Draggable component to be summarized in this article also has two loading methods:
(1) Use the class loading method:
Content
(2) JS loading and calling
$ ('# Box'). draggable ();
As mentioned above, using the class attribute is not conducive to expanding other attributes of the component. Therefore, we use the JS call method, and the subsequent articles also use the JS call method.
This component has several attributes, methods, and trigger events, which are not listed here. They are all put in the sample code and annotated.
Example:
JQuery Easy UI
<Script type = "text/javascript" src = "easyui/jquery. min. js "> </script> <script type =" text/javascript "src =" easyui/jquery. easyui. min. js "> </script> <script type =" text/javascript "src =" easyui/locale/easyui-lang-zh_CN.js "> </script>
<Script> $ (function () {$. fn. draggable. defaults. cursor = 'text'; // ***** use this method to override the default value $ ('# box '). draggable ({// revert: true, the default value is false. When the value is set to true, the start position is returned after the drag ends. // cursor: 'text ', define the pointer style when dragging. // handle: '# pox'. The handle used to start dragging is where you can drag the pointer. The parameter is a JQ selector // disabled: true, when it is set to true, do not drag // edge: 0, // axis: 'V', do not write: any drag value is v: vertical drag value is h: horizontal drag // proxy: 'clone '. When 'clone' is used, clone an alternative element and drag it. If a function is specified, you can customize the substitution element. DeltaX: 50, // The dragged element corresponds to the current cursor position XdeltaY: 50, // The dragged element corresponds to the current cursor position Yproxy: function (source) {var p = {('{}p.html({(source}.html ()). appendTo ('body'); return p;}/** trigger event: onBeforeDrag: function (e) {alert ('trigger before dragging! ') ;}, OnBeforeDrag: function (e) {// return false ;}, onStartDrag: function (e) {alert ('drag to start triggering! '); Console. log ($ ('# box '). draggable ('proxy');}, onDrag: function (e) {// alert ('triggered during dragging! ') ;}, OnStopDrag: function (e) {alert (' triggered after the drag ends! ');} */}); // $ (' # Box '). draggable ('disable'); // drag prohibited // $ ('# box '). draggable ('enable'); // you can drag it. // alert ($ ('# box '). draggable ('options'); // returns object attributes}); </script>Content
Click to download source code