0

I'm trying to underline the tab with the asp .net ajax control toolkit tabcontainer that is currently selected and set the aria-selected attribute for section 508. I have tried several different ways to do this. I am using the following code that has been setup to run on each partial postback of an update panel.

function pageLoadHandle(sender, Aargs) {
    var tabHeader = $('.ajax__tab_active');
    var allTabs = $('.ajax__tab_inner');
    for (var i = 0; i <= allTabs.length - 1; i++) {
        var tab = allTabs[i];
        tab.setAttribute("aria-selected", "false");
    }
    var tabAnchor = tabHeader.find("a[class=ajax__tab_tab]");
    //alert(tabAnchor);
    tabAnchor.attr("aria-selected", "true");
    tabAnchor.css("text-decoration", "underline");
}

The problem that I am seeing is that neither the aria-selected attribute is being set to true or the text is being underline. If you have some suggestions on how to get this working correctly, please let me know. I think the problem is that I am using the wrong query in the .find() method, but dang it, I'm confused. TIA

I'm pulling my hair out on this, so expect some stupidity here. :-)

Wallace B. McClure
  • 1,165
  • 1
  • 15
  • 31
  • I finally found the solution to this problem. I was running this code on the client side pageload event. That seems to be the wrong time to do this. Yes, it needs to run on the page load event. I also started experimenting with this on the end request event, and that seems to be working. – Wallace B. McClure Aug 20 '20 at 01:32
  • Ok, so one add in to this, and it is important. The underline and the attributes seem to work fine in the pageLoaded client side asp.net ajax client side javascript event, but they only seem to work right the first time. I also had to add this code to run on the end request client side event. The interesting thing is that the end request event didn't run on the first load of the page, which actually makes since end request only runs after an async page request. Bottom line, I had to run this in both events. Hopefully, some of this helps. :-) – Wallace B. McClure Aug 20 '20 at 19:24

0 Answers0