Open In App

jQuery UI Sortable receive Event

jQuery UI is a web-based technology and consists of various GUI widgets, visual effects, and themes. These features can be implemented using the jQuery JavaScript Library. jQuery UI is the best tool for building UI interfaces for the webpages. It can also be used to build highly interactive web applications or can be used to add widgets easily.

The jQuery UI Sortable receive Event is used to trigger when an item from a connected sortable list has been dropped into another list.



Syntax:

Parameters: These are the following parameters that are accepted. 

CDN Link: Below are some jQuery Mobile scripts that will be needed for your project so add these to your project.

<link rel=”stylesheet” href=”https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css”>
<script src= “https://code.jquery.com/jquery-1.12.4.js”></script>
<script src= “https://code.jquery.com/ui/1.12.1/jquery-ui.js”></script>

Example: This example describes the uses of the jQuery UI Sortable receive Event.




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="utf-8">
    <link rel="stylesheet"
          href=
    <script 
          src=
    </script>
    <script 
          src=
    </script>
  
    <style>
        #sortable-1, #sortable-2 { 
            list-style-type: none; 
            width: 150px; 
            }
        #sortable-1 li, #sortable-2 li { 
            padding: 0.4em; 
            font-size: 17px; 
            height: 16px; 
            color: black;
            background-color: green;
        }
  
    </style>
  
    <script>
        $(function() {
            $( "#sortable-1" ).sortable({
                   receive : function (event, ui) {
                    $(".res").html ($(".res").html () 
                     + "<b>Receive</b><br>");
                   }
            });
            $( "#sortable-2" ).sortable({
                   connectWith : "#sortable-1, #sortable-2"
            });
        });
    </script>
  
</head>
  
<body>
    <center>
        <h1 style="color: green;">
            GeeksforGeeks
        </h1>
  
        <h4>jQuery UI Sortable receive Event</h4>
  
        <hr />
        <div class = "list_data">
            <div class = "list_data1"
                <h3>Name</h3>
                <ul id = "sortable-1">
                    <li class = "ui-state-default">GFG1</li>
                    <li class = "ui-state-default">GFG2</li>
                    <li class = "ui-state-default">GFG3</li>
                </ul>
            </div>
            <div class = "list_data1">
                <h3>Mark</h3
                <ul id = "sortable-2">
                    <li class = "ui-state-default">90</li>
                    <li class = "ui-state-default">80</li>
                    <li class = "ui-state-default">70</li>
                </ul>
            </div>
        </div>
          
        <hr />
        <div class="res"></div>
    </center>
</body>
  
</html>

Output:

Reference: https://api.jqueryui.com/sortable/#event-receive 


Article Tags :