Tabs in Bootstrap with spaces within the URL

I have made some modifications to the Bootstrap Tabs, where I am now pulling the ID from a controller instead of specifying them directly.

Everything is working perfectly, except for the tabs with IDs that have spaces between words. These tabs are not functioning as expected.

In summary, single-word tabs work fine, but tabs with multiple words do not work.

Below is the updated code:

<!-- Nav tabs -->
    <ul class="nav nav-tabs" role="tablist">
        @foreach (var qs in Model)
        {
            <li role="presentation"><a href="#@qs.QuestionSectionName" aria-controls="home" role="tab" data-toggle="tab">@qs.QuestionSectionName</a></li>
        }
    </ul>

    <!-- Tab panes -->
    <div class="tab-content">
        @foreach (var qs in Model)
        {
           <div role="tabpanel" class="tab-pane active" id="@qs.QuestionSectionName">
               <table class="table">
                   <tbody>

                       @foreach (var item in qs.Questions)
                       {
                           <tr>
                               <td>
                                   @Html.DisplayFor(modelItem => item.QuestionName)
                               </td>
                               <td>
                                   @Html.DisplayFor(modelItem => item.QuestionSection.QuestionSectionName)
                               </td>
                           </tr>
                       }
                   </tbody>
               </table>

           </div> 
        }
    </div>

Thank you.

Answer №1

Once triggered, Bootstrap searches for a matching .tab-pane with an exclusive identifier, but it faces the limitation that IDs must not have spaces.

You will need to use hyphens in place of spaces for the value(s) of the @qs.QuestionSectionName as it progresses through the iteration.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to create a responsive header image on a website

I recently incorporated a header image on my website using the following code: #header_area { background: url('my_header_image.com'); background-repeat: no-repeat; background-position: top center; } Although my website is responsive ...

Issues with Collapse Feature on Bootstrap 3 Navbar

I need your help with a problem I'm facing. The navigation bar is not collapsing when I click the link in mobile view. Check out this video for more details: https://www.youtube.com/watch?v=2dBpcFMjqY0 ...

Letters are frolicking in varying sizes and designs

Currently, I am encountering a strange issue with the text on my webpage. Some fonts are displaying with completely different shapes and sizes despite using <meta charset="UTF-8"> to ensure font consistency. Unfortunately, this did not resolve the pr ...

Tips for optimizing background images for various screen sizes?

I'm experiencing an issue with my background image where the head is being cut off on larger screens. Is there a way to ensure that the entire picture is always displayed regardless of screen size? The initial property for background-size is set to co ...

arrange a div inside another div

I'm struggling to grasp the concept of how divs function in HTML. Below is a snippet of my HTML code: <div id="user_p"> <img src="img/pp/djbaptou.jpg"> <div class="followings"> djbaptou </br> Baptiste Arnaud </br> ...

Is there a way to connect CSS files from a different directory?

I'm currently in the process of developing a website and I encountered an issue with linking my CSS file, which is stored in a different folder. I originally had it in the same directory as my HTML code, but now I need to figure out how to link it pro ...

Is there a way to adjust the height of a span element without causing the page to

I recently created an animation featuring a starfield effect using small, rotating radial gradients. However, there is a noticeable ending point when the gradients stop rotating. I found that increasing the background height solves this issue, but it also ...

Anchor tags created using JQuery will remain on the same page without redirecting

Presented below is the code I have utilized to construct the anchor tag along with its content. $('div#right-slide').html("<a href=\"http://www.XXXXXXXXXXXX.info/limited-specials/\" ><h1 id=\"specials\">Click Here ...

Is there a way to compile LESS files that include @import statements for other LESS files?

I am currently in the process of converting Twitter Bootstrap's LESS files into the necessary CSS files for Bootstrap to function. I have attempted to use LESS and SimpLESS, but encountered errors with both. According to a discussion on Stack Overflow ...

Deactivating one div's class upon clicking on another div

Below is the HTML code snippet: <div class="container"> <ul class="navbar"> <li class="nb-link"><a>Home</a></li> <li class="dropdown"> <a>CBSE</a> <ul class="dropdown-menu"&g ...

Execute .jar Files on Mac Big Sur by simply clicking

Recently, I made the switch from Windows to Mac and encountered a problem when trying to open an executable .jar file by clicking on its icon in Finder. It seems that Mac does not have the capability to execute .jar files with ease like Windows, requiring ...

Positioning CSS Div After Absolute Positioning Div

Can anyone provide guidance on how to smoothly continue the flow of a page using CSS? Let me explain my current dilemma: I have 3 divs - div 1 (parent), div 1 (child), and div 2 (normal). The parent div is absolute, the child is relative. Everything seem ...

Display additional text when hovering over an object

Is there a way to make my text expand and display all of its content when hovered over, especially for those sections that are longer than the div size? I currently have some code implemented, but it seems to reveal the text horizontally. I am looking fo ...

Eclipse doesn't provide the option to import in order to resolve an unidentified reference

After being away from Eclipse for an extended period of time, I've encountered a problem trying to execute a basic Selenium program. Specifically, in my main() function, I am attempting to create a new instance of Webdriver. WebDriver driver = new Ch ...

Using Selenium to input test data on a webpage using a nested LinkedHashMap, with a focus on efficiently handling radio buttons

Currently, I am utilizing Selenium with Java within a POM based hybrid framework. My goal is to create a universal function for inputting data on webpages. This function takes in a LinkedHashMap containing key-value pairs of web elements and test data to b ...

Unique style CSS (Flex)Grid with spacing and uniform aspect ratio

Hello everyone, typically I'm quite skilled when it comes to CSS but this particular challenge has pushed me to my limits. I have a desire to create a grid where all elements maintain the same aspect ratio (with images that already share this aspect ...

Passing data to an iframe through Ajax request

I have been devoting my time to a special project, and I can proudly say that I am almost done with it. However, the hurdle I am facing right now revolves around the concept of *sending parameter to iframe*. My primary objective is to craft a basic editor ...

Unable to store webpage using selenium automation

I'm having trouble with the save button at the end of the process. It doesn't seem to respond to my clicks. System.setProperty("webdriver.chrome.driver" , "C:\\Users\\gausia.fatima\\Downloads\\automation&b ...

Consistent height for h2 containers across all CSS grid columns

Is there a way to ensure all h2 containers have the same height, both with JavaScript and without it? The h2 titles are dynamic and can vary in length, but I want to maximize the space for all containers. img { max-width: 100%; height: auto; } .gri ...

Problem with items overlapping in hoverable drop-down menu

I have been attempting to create a hoverable dropdown menu, but I am encountering an issue where the items of the dropdown are overlapping. Despite my efforts to adjust the CSS classes, I have not been successful in fixing this problem. Additionally, I ha ...