jQuery UI Sortable refreshPositions() Method
Last Updated :
12 Jan, 2022
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 Sortable refreshPositions() Method to refresh the sortable items. It riggers the reloading of all sortable items and allow new items to be recognized.
Syntax:
$( ".selector" ).sortable( "refreshPositions" );
Parameters: This method does not accept any parameter.
Return Value: This method returns an object value.
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 refreshPositions() Method.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<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>
<style>
#sortable {
list-style-type: none;
}
#sortable li {
margin: 5px 5px 5px 5px;
padding: 1px;
width: 250px;
height: 40px;
font-size: 25px;
color: black;
background-color: green;
}
</style>
<script>
$(function() {
$("#sortable").sortable({
stop: function(ev, ui) {
var children = $('#sortable')
.sortable('refreshPositions')
.children();
alert('Positions: ');
$.each(children, function() {
alert($(this).attr('id'));
});
}
});
});
</script>
</head>
<body>
<center>
<h1 style="color: green;">
GeeksforGeeks
</h1>
<h4>jQuery UI Sortable refreshPositions() Method</h4>
<div class = "list_data">
<div class = "list_data1">
<ul id = "sortable">
<li class = "ui-state-default"
id = "Geeks1">Geeks1</li>
<li class = "ui-state-default"
id = "Geeks2">Geeks2</li>
<li class = "ui-state-default"
id = "Geeks3">Geeks3</li>
</ul>
</div>
</div>
</center>
</body>
</html>
Output:
Reference: https://api.jqueryui.com/sortable/#method-refreshPositions
Similar Reads
jQuery UI Sortable refresh() Method 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 appl
2 min read
jQuery UI Sortable option() Method jQuery UI is a web-based technology and consists of GUI widgets, visual effects, and themes 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
3 min read
jQuery UI Selectable refresh() Method jQuery UI consists of GUI widgets, visual effects, and themes implemented using the jQuery, JavaScript Library. jQuery UI is great for building UI interfaces for the webpages. It can be used to build highly interactive web applications or can be used to add widgets easily. In this article, we will b
2 min read
jQuery UI Sortable serialize() Method 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 appl
2 min read
jQuery UI Sortable revert Option jQuery UI consists of GUI widgets, visual effects, and themes implemented using HTML, CSS, and jQuery. jQuery UI is great for building UI interfaces for the webpages. The jQuery UI Sortable revert Option is used to check whether the sortable items should revert to their new positions using a smooth
1 min read