Open In App

jQuery UI Droppable create Event

Last Updated : 07 Feb, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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.

In this article, we will be using the jQuery UI Droppable create Event to trigger when the droppable is created.

Syntax:

We need to initialize the droppable widget with the create a callback function

$( ".selector" ).droppable({

create : function( event, ui ) {}

});

Bind an event listener to the drop create event:

$( ".selector" ).on( "dropcreate ", function( event, ui ) {} );

Parameters: These are the following parameters that are accepted.  

  • event: This event is triggered when the sort creates an item.
  • ui: This parameter is of type object. The ui object is empty but included for consistency with other events.

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 Droppable create Event.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="utf-8">
    <link href=
          rel="stylesheet">
    <script src=
    </script>
    <script src=
    </script>
  
    <style>
        .dragg {
            width: 90px;
            height: 50px;
            border: 1px solid black;
            background-color: blue;
        }
  
        .dropp2 {
            width: 200px;
            height: 50px;
            border: 1px solid black;
            float: center;
            background-color: green;
        }
    </style>
  
    <script>
        $(function () {
            $(".dragg").draggable();
            $(".dropp2").droppable({
                create: function (event, ui) {
                    $(".res").html($(".res").html()
                        + "<b>Droppable Widget has been created.</b><br>");
                }
            });
        });
    </script>
</head>
  
<body>
    <center>
        <h1 style="color:green;">GeeksforGeeks</h1>
  
        <h3>jQuery UI Droppable create Event</h3>
  
        <div class="dragg">
            <p>Drag</p>
  
        </div>
        <br>
        <div class="dropp2">
            <p>Drop here</p>
  
        </div>
        <br>
        <div class="res"></div>
    </center>
</body>
  
</html>


Output:

jQuery UI Droppable create Event

jQuery UI Droppable create Event

References: https://api.jqueryui.com/droppable/#event-create



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads