Skip to content
Related Articles

Related Articles

jQuery UI Selectable autoRefresh Option

Improve Article
Save Article
Like Article
  • Last Updated : 18 Dec, 2021

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.

The jQuery UI Selectable autoRefresh option is used to determine whether to refresh the position and size of each selected item. This option is set to “false” if you have many items.

Syntax:

Initialize selectable element with autoRefresh option:

$(".selector").selectable({
   autoRefresh: false
});

Set or return autoRefresh option after initialization: 

// Set the autoRefresh option
$( ".selector" ).selectable( "option", "autoRefresh", false );

// Return the autoRefresh option
var auto_refresh = $( ".selector" )
  .selectable( "option", "autoRefresh" )

CDN links: 

<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: 

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>
        .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>
  </head>
  <body>
       <h1>GeeksforGeeks</h1>
       <h3>jQuery UI Selectable  autoRefresh Option</h3>
       <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>
       <script>
          $(".grid").selectable({
            autoRefresh: true,
          });
       </script>
  </body>
</html>

Output:

Reference: https://api.jqueryui.com/selectable/#option-autoRefresh


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!