Open In App

EasyUI jQuery Draggable widget

In this article, we will learn how to design a draggable widget using jQuery EasyUI. EasyUI is an HTML5 framework for using user interface components based on jQuery, React, Angular, and Vue technologies. It helps in building features for interactive web and mobile applications saving a lot of time for developers.

The widget creates a draggable element from markup or selector.



Download EasyUI for jQuery:

https://www.jeasyui.com/download/index.php

Syntax:



var a = $(".selector").draggable({
    
});

Properties:

Events:

Methods:

Note: In the following examples only a few examples are shown, the developer can try out other properties, events, and methods listed above as per the application’s requirement.

CDN Links: First, add jQuery Easy UI scripts needed for your project.

<script type=”text/javascript” src=”jquery.min.js”></script>   
<!–jQuery libraries of EasyUI –> 
<script type=”text/javascript” src=”jquery.easyui.min.js”></script>   
<!–jQuery library of EasyUI Mobile –> 
<script type=”text/javascript” src=”jquery.easyui.mobile.js”></script>  
 

Example: The following example demonstrates jQuery EasyUI Draggable widget.




<!DOCTYPE html>
<html>
  
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="initial-scale=1.0, maximum-scale=1.0,
                   user-scalable=no">
              
    <!-- EasyUI specific stylesheets-->
    <link rel="stylesheet" type="text/css"
          href="themes/metro/easyui.css">
  
    <link rel="stylesheet" type="text/css"
          href="themes/mobile.css">
  
    <link rel="stylesheet" type="text/css"
          href="themes/icon.css">
  
    <!--jQuery library -->
    <script type="text/javascript" src="jquery.min.js">
    </script>
  
    <!--jQuery libraries of EasyUI -->
    <script type="text/javascript"
            src="jquery.easyui.min.js">
    </script>
      
    <!--jQuery library of EasyUI Mobile -->
    <script type="text/javascript"
            src="jquery.easyui.mobile.js">
    </script>
  
    <script type="text/javascript">
        $(document).ready(function (){
            $('#gfg1').draggable({
                handle:'#drag1',
            });
        });
 
        $(document).ready(function (){
            $('#gfg').draggable({
                handle:'#drag',
                cursor: 'pointer',
                revert: 'true'
            });
        });
    </script>
</head>
  
<body>
     
    <h1>GeeksforGeeks</h1>
    <h3>EasyUI Draggable Widget</h3>
    <div id="gfg">
        <div id="drag"
             style="background:rgb(199, 199, 199);
                    width: 180px;">
            
<p>Revert Draggable Element
<p>
        </div>
    </div>
    <div id="gfg1">
        <div id="drag1"
             style="background:rgb(199, 199, 199);
                    width: 180px;">
            
<p>Draggable Element
<p>
        </div>
    </div>
     
</body>
  
</html>

Output:

Reference: http://www.jeasyui.com/documentation/


Article Tags :