In this tutorial we will learn how to create drag and drop with sorting functionality with help of jQuery UI. That means we are able to move the object from one location container to another location container.
Sometimes we need to drag one object from location to other location so we need to provide drag and drop with jquery.
Checkout other tutorial of jQuery,
Step 1: Include the below files in section of files. These are jQuery and jQuery UI file.
<script src="http://code.jquery.com/jquery-1.8.2.js"></script> <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
Step 2: We will Define HTML Structure or HTML view file to show drag and drop elements list.HTML structure of jQuery UI Sortable is very easy, just we define div
as a parent with a specific id and keep all items as the list based on ul
and li
the combination as follows.
<!-- Main component for a primary marketing message or call to action --> <h1>Test</h1> <div id="sortable-div" class="col-sm-12 col-xs-12 col-md-9 addSub"> <div class="padLR10"></div> <div id="dragdrop" class="col-sm-4 col-xs-4 col-md-4"> <div class="well clearfix"> <div class="header">Container 1</div> <div class="dragbleList"> <ul class="sortable-list"> <li class="sortable-item">Item1</li> <li class="sortable-item">Item2</li> <li class="sortable-item">Item3</li> <li class="sortable-item">Item4</li> </ul> </div> </div> </div> <div id="dragdrop" class="col-sm-4 col-xs-4 col-md-4"> <div class="well clearfix"> <div class="header">Container 2</div> <ul class="sortable-list"> <li class="sortable-item">Item51</li> <li class="sortable-item">Item52</li> <li class="sortable-item">Item53</li> <li class="sortable-item">Item54</li> </ul> </div> </div> <div id="dragdrop" class="col-sm-4 col-xs-4 col-md-4"> <div id="my-timesheet" class="well clearfix"> <div class="header">Container 3</div> <ul class="sortable-list"> <li class="sortable-item">Item6</li> <li class="sortable-item">Item7</li> <li class="sortable-item">Item8</li> <li class="sortable-item">Item9</li> </ul> </div> </div> </div>
Step 3: Now we will initializing UI Sortable with help of sortable function.
$(document).ready(function(){ // Example 1.3: Sortable and connectable lists with visual helper $('#sortable-div .sortable-list').sortable({ connectWith: '#sortable-div .sortable-list', placeholder: 'placeholder', }); });
This code will be called on jquery on document-ready
.We have passed sortable-div
and .sortable-list
for drag and drop elements containers.
This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More
in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More
This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More
We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More
in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More
I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More
View Comments
It does not serve to download
enabled download link
its working like charm 🙄