fueanta

JS hack for telerik tab select on page load

Oct 4th, 2021
1,013
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const selectTelerikTab = tabIndex => {
  2.   const tabs = document.querySelectorAll("#banner-list > ul > li");
  3.   if (tabIndex >= 0 && tabIndex < tabs.length) {
  4.     tabs[tabIndex].click();
  5.   }
  6. };
  7. $(document).ready(function () {
  8.   const searchParams = new URLSearchParams(window.location.search);
  9.   if (searchParams.has("tabIndex")) {
  10.     const tabIndex = parseInt(searchParams.get("tabIndex"));
  11.     if (tabIndex) {
  12.       selectTelerikTab(tabIndex);
  13.     }
  14.   }
  15. });
RAW Paste Data