Open In App

jQuery UI Selectable refresh() Method

Last Updated : 14 Jan, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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=
    <script src=
    </script>
    <script src=
    </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:

jQuery UI Selectable refresh() Method

Reference: https://api.jqueryui.com/selectable/#method-refresh



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads