HelpBot Assistant

How can I help you?

Getting started in EJ2 JavaScript Spinner control

10 Feb 20263 minutes to read

This section explains the steps required to create a simple Essential® JS 2 Spinner and demonstrate the basic usage of the Spinner control in a JavaScript application.

Dependencies

The following list of dependencies are required to use spinner in your application.

|-- @syncfusion/ej2-popups
    |-- @syncfusion/ej2-base

Setup for local environment

Refer to the following steps to set up your local environment.

Step 1: Create a root folder named my-app for your application.

Step 2: Create a my-app/resources folder to store local scripts and styles files.

Step 3: Open Visual Studio Code and create my-app/index.js and my-app/index.html files to initialize the Essential® JS 2 Spinner control.

Create Spinner

Initialize the Spinner using the createSpinner method and show/hide the spinner using the showSpinner and hideSpinner methods. Set the target to render the spinner based on a specific element:

  createSpinner({
    target: document.getElementById('container')
  });
  • Show and hide this spinner by using showSpinner and hideSpinner methods for loading in your page.

Create the Spinner globally

The Spinner can be render globally in a page using public exported functions of the ej.popups.

//createSpinner() method is used to create spinner

ej.popups.createSpinner({

  // Specify the target for the spinner to show

  target: document.getElementById('container')

});

//showSpinner() will make the spinner visible

ej.popups.showSpinner(document.getElementById('container'));

setInterval(function () {

  //hideSpinner() method used hide spinner 

  ej.popups.hideSpinner(document.getElementById('container'))

}, 100000);
<!DOCTYPE html><html lang="en"><head>
    <title>EJ2 Spinner</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="TypeScript NumericTextBox Component">
    <meta name="author" content="Syncfusion">
    <link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-base/styles/material.css" rel="stylesheet">
    <link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-popups/styles/material.css" rel="stylesheet">
    
    
<script src="https://cdn.syncfusion.com/ej2/32.2.3/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
    <div id="container">
       
    </div>

<script>
var ele = document.getElementById('container');
if(ele) {
  ele.style.visibility = "visible";
}   
      </script>
<script src="index.js" type="text/javascript"></script>
</body></html>