Switching to JS version 3.3.7 causes the Bootstrap tabs to malfunction

After reviewing the Bootstrap documentation for version 3.3.7, I may have overlooked something.

The issue I am facing is that my dropdown menu does not function properly when using the CDN for Bootstrap JS v3.3.6, but it works fine when switched to v3.3.7.

However, upon changing to v3.3.7, my tabs cease to work as expected.

Removing the Bootstrap JS link makes the tabs functional again.

<!doctype html>
<html>
<head>
    <title>Quiz App!</title>
    <link rel="icon" type="image/png" href="http://plainicon.com/dboard/userprod/2921_4eb4c/prod_thumb/plainicon.com-64851-256px-36c.png">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <h2 id="header"><span class="glyphicon glyphicon-grain"></span> <small>(in development)</small></h2> </hr>
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active"><a href="/" aria-controls="home2" data-toggle="tab"><span class="glyphicon glyphicon-home"></span></a></li>
                <li role="presentation" class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
                        Featured Topics<span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="/topics/us-presidents" data-toggle="tab">U.S. Presidents</a></li>
                        <li><a href="/topics/business" data-toggle="tab">Business & Investing</a></li>
                        <li><a href="/topics/astronomy" data-toggle="tab">Astronomy</a></li>
                        <li><a href="/topics/movies" data-toggle="tab">Movies</a></li>
                    </ul>
                </li>
                <li role="presentation"><a href="/all-quizzes" aria-controls="rankings" data-toggle="tab">All Quizzes</span></a></li>
                <li role="presentation"><a href="/create-quiz" aria-controls="stats" data-toggle="tab">Create a Quiz</span></a></li>
            </ul>
        </div>
    </div;

        {{{body}}}
</div>
</body>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

</html>

Your assistance in this matter would be greatly appreciated.

Answer №1

The issue at the core of your problem lies in how the href attribute is used in the links within the tabs. To ensure compatibility with Bootstrap JS, it is important that these links reference local content, such as a div id, like so:

<a href="#all-quizzes" aria-controls="rankings" data-toggle="tab">All Quizzes</span></a>

The problem arises when Bootstrap JS encounters the relative path in your link and triggers an error (which can be seen in the console upon clicking on the tab).

If you delve into the source code of Bootstrap 3.3.7 to examine tabs.js, you will notice that it examines (at line 29) the data-target attribute of the clicked element (tab), and if empty, resorts to the href attribute (line 32). It then attempts to use this value as a jQuery selector (line 51) to locate the element, which fails in your scenario.

For instance, when you select the All Quizzes tab, the JS endeavors to execute: $('/all-quizzes') resulting in an error due to invalid jQuery selector syntax.

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

Using Bootstrap in Rails: Positioning a dropup to align with another element in a footer

I am attempting to align the content as a footer, but having trouble with the dropup not lining up properly: <footer class="footer"> <div class="container-fluid"> <div class="row"> <div class="col-xs-12 col-sm-12 col-md-12"> &l ...

Firing a unique jQuery event without triggering bubbling

I am looking for a way to trigger a unique jQuery event on an object that does not bubble. While I know that I can use return false or stopPropagation to prevent bubbling, I am wondering if there is a way to trigger a custom event and specify that it shoul ...

JSON - Select2 Data Structure

Looking for guidance on manipulating JSON values. {"items":[ {"id":1,"parent_id":0,"name":"Root Catalog"}, {"id":2,"parent_id":1,"name":"Category1"}, ...

Seamless transition of text positioning and opacity as you scroll

After exploring multiple techniques for changing opacity and position on scroll, I am still struggling to connect them effectively. What I'm Looking For: I have a container with 4 words in a row. Only one word should be visible at a time, transition ...

Tips for deleting a text node preceding a div element?

Here's the HTML code snippet I am currently working with: <div id="wrapper"> <div id="some-id"></div> "this is some texxt" <div id="some-id-2"></div> </div> Is there a way to eliminate the text using CSS? ...

Using AJAX to send data to a new URL via a POST request

I'm currently developing an event registration page that requires users to search for a specific item in the database in order to register for the event. To ensure that the form wizard sequence is not disrupted, the POST request needs to be submitted ...

Enable automatic scrolling when a button on the previous page has been clicked

Imagine there are two buttons (Button 1 and Button 2) on a webpage (Page A). Clicking on either button will take you to the same external page (Page B). How can we ensure that Button 1 takes you to the top of Page B, while Button 2 automatically scrolls do ...

Is anyone experiencing difficulties with IOS 8.3 when trying to assign colors to Font Awesome icons using content?

I'm encountering an issue on IOS 8.3 where I click a checkbox and the arrow color should be green, but it shows up as black instead. Is there a bug fix for this in IOS or is it simply not supported? Here is my SASS/css code: input[type="checkbox"] ...

What is the best way to link the value of a mat-slider to an input field in a reactive form?

Is there a way to synchronize the min and max values of a ranged mat-slider with corresponding input fields? Currently, when I set numbers in the input fields, the slider updates correctly. However, when I use the slider to change the value of the input fi ...

How do you send a variable in a GET request with React?

My challenge is to retrieve data from a table where the teacherId matches the teacherId of the user who logs in, but I am facing difficulties in passing this teacherId from the front-end to the back-end. Below is the backend code: app.get("/api/get&q ...

creating a picture within a frame

the code : function DrawFirstRow() { Position = 1; width = 84; height = 84; startX = 28; startY = 28; for (index = 0; index < canvasWidth; index += 28) { /// use += ctx.drawImage(tankImage, (Position ...

Displaying JSON as a table using React JS

I can't seem to display JSON data in a table using the useState hook in React, and I'm not sure why. Here's a snippet from my React file: {` import React, { useState } from 'react' import "../styling/Classes.css"; import data ...

JavaScript loop through an array of objects

Is there a way to loop through and retrieve all of the addresses? const name = { john: [ { age: 21, address: 'LA', } ], sam: [ { age: 26, address: 'California' } ] } I have tried using th ...

When using XMLHttpRequest() to fetch a JSON file, why do I receive an empty string when I try to log the responseText?

Upon executing console.log(getErrors), the following output is displayed in the console: XMLHttpRequest {statusText: "", status: 0, responseURL: "", response: "", responseType: ""...} onabort: null onerror: null ... responseText: {"content":[{"id":1,"time ...

Having trouble connecting Heroku to my asset javascript and css files within my Rails application

After deploying my app on Heroku, I encountered an issue where my scripts and CSS files are not properly linked. While everything works fine locally, the same does not hold true in the production environment. This is how I am rendering my scripts and CSS ...

A guide to triggering AlertIOS in React Native

As an iOS developer with limited knowledge of javascript, I am currently attempting to utilize the AlertIOS function. The provided document API for AlertIOS is as follows: static alert(title: string, message?: string, buttons?: Array<{ text: ?string; on ...

Utilizing Animated GIFs as Textures in THREE.js

I'm trying to figure out how to incorporate a GIF animation as a texture in THREE.js. While I can successfully load a texture (even in GIF format), the animation doesn't play. Is there a solution to this? I came across some resources like these: ...

Unpacking default function parameters in Vue.js and understanding the 'this' keyword

Is there a way to correctly reference the data object using this when setting default parameters with destructuring in Vue.js? activated () { this.fillData() }, data () { return { chartData: { distributionInitialData: { // data he ...

Trigger is not activated by dynamically created element

I am dealing with a block of code that is dynamic and looks like this. var li3 = document.createElement('li'); li3.classList.add("col-sm-3"); li3.classList.add("no_padding"); var inner = ""; inner = inner ...

What is the reason for jquery requiring _$ when overwriting?

var // Optimizing references to window and allowing renaming window = this, // Increasing efficiency in referencing undefined and enabling renaming undefined, // Creating aliases in case of jQuery overwrite _jQuery = window.jQuery, // Creating aliases in ...