jQuery UI Selectable refresh() Method
Last Updated :
14 Jan, 2022
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 be using the jQuery Mobile Selectable refresh() method to refresh the position and size of each selected element. This refresh function is used to manually recalculate the position and size of each selector. For this, we need to set the autoRefresh option as false. It does not accept any parameter for functioning.
Syntax:
$(".selector" ).selectable( "refresh" );
Parameters: This method does not accept any arguments.
CDN Links: Add the following jQuery Mobile scripts to your project.
<link rel=”stylesheet” href=”https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css”/>
<script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js”></script>
<script src=”https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js”></script>
Example: This example describes the uses of the jQuery Mobile Selectable refresh() method.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet"
href=
"https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css"/>
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js">
</script>
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js">
</script>
<style>
.GFG{
float: center;
}
.grid {
display: grid;
grid-template-columns: 50px 50px 50px;
gap: 10px;
}
.grid-item {
width: 50px;
height: 50px;
background-color: aqua;
}
.ui-selected {
background-color: green;
}
.ui-selecting {
background-color: rgb(122, 255, 122);
}
</style>
<script>
$(function () {
$("#btn").on('click', function () {
$(".grid").selectable( "refresh" );
alert("Widget Refreshed");
});
});
$(".grid").selectable();
</script>
</head>
<body>
<center>
<h1 style = "color:green;">GeeksforGeeks</h1>
<h3>jQuery UI Selectable refresh() Method</h3>
<div class="GFG">
<div class="grid">
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
</div>
</div>
<input type="button" id="btn"
value="Refresh the Widget">
</center>
</body>
</html>
Output:
Reference: https://api.jqueryui.com/selectable/#method-refresh
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 Tabs refresh() Method 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 Tabs widget is used to create a single content area with multiple panels that are associated with a header in a list. T
3 min read
jQuery Mobile Selectmenu refresh() Method jQuery Mobile is a web-based technology used to make responsive content that can be accessed on all smartphones, tablets, and desktops. In this article, we will be using the jQuery Mobile Selectmenu refresh() method. This will parse the original element and re-renders the menu. Syntax: $( "selector"
1 min read
jQuery UI Sortable refreshPositions() 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 Selectable option() 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
3 min read