Articles in this section
Category / Section

How to disable the JavaScript Sidebar and its inner elements?

1 min read

How to disable the Sidebar and its child elements?

 

Sidebar component has no direct property to disable itself and its inner HTML elements. However, it is possible to restrict the interactions to the Sidebar and its child elements in a HTML page. To disable and prevent user interactions, the pointer-events, opacity (CSS properties) and HTML tabIndex attribute in the Sidebar element can be manipulated using the created event of Sidebar. 

 

In the following example, a custom CSS class disable has been added into the class list of the element of Sidebar. By using disable class as class selector, the CSS properties (pointer-events, opacity) were applied to disable the user interactions and added opacity.

 

Note:

The disable class can be removed from the classList of the Sidebar element to enable it, again. 

 

 

<ejs-sidebar id="default-sidebar" created="onCreated"></ejs-sidebar>

 

function onCreated(args) { 
        defaultSidebarObj = document.getElementById('default-sidebar').ej2_instances[0]; 
        defaultSidebarObj.element.classList.add("disable");
             defaultSidebarObj.element.setAttribute('tabindex', '-1');
    } 

 

.disable { 
        pointer-events: none; 
        user-select: none; 
        opacity: 0.50; 
    } 

 

 

Sample: https://www.syncfusion.com/downloads/support/directtrac/217161/ze/COREEJ~12022112419

 

Live Sample: https://stackblitz.com/edit/hjdl6y?file=index.html

 

 

Conclusion

I hope you enjoyed learning about how to disable the JavaScript Sidebar and its inner elements.

You can refer to our JavaScript Sidebar feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our JavaScript Sidebar example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied