Topic: Events for tabs don't work

maksam07 free asked 8 months ago

Good afternoon, I was trying to track the event when a tab is opened:

$('a[data-mdb-toggle="tab"]').on('', function (e) {

But it didn't work out for me. The console was blank when I switched tabs.

I was looking for a solution for a long time until I decided to try the same event but from bootstrap:

$('a[data-mdb-toggle="tab"]').on('', function (e) {

And when switching tabs, the console started displaying the text ""

How do I track down why this problem is happening? Both event handlers are next to each other, they should both fire at the same time, but only the bootstrap event fires.

Expected behavior

When opening a tab, output text to the console

Actual behavior

The console is empty

Resources (screenshots, code snippets etc.)

The template has roughly the following code:

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <meta http-equiv="x-ua-compatible" content="ie=edge"/>

    <link rel="stylesheet" href="/static/lib/fontawesome-free-6.4.2-web/css/all.min.css">
    <link rel="stylesheet" href="/static/css/fonts.css">
    <link rel="stylesheet" href="/static/lib/mdb/css/mdb.min.css"/>
    <link rel="stylesheet" href="/static/css/style.css">


<script type="text/javascript" src="/static/lib/mdb/js/mdb.min.js"></script>
<script src="/static/js/jquery-3.7.1.min.js"></script>
<script src="/static/js/common.js"></script>

Kamila Pieńkowska staff answered 8 months ago

Which version are you using? In the current version (6.4.2) both MDB and Bootstrap events are triggered.

maksam07 free commented 8 months ago

Why are only bs events triggered?

maksam07 free commented 8 months ago

Please check this code NOT in snippet, but in any other editor. Because for some reason my code in snippet seems to work without any problem, but in jsfiddle it doesn't

Kamila Pieńkowska staff commented 8 months ago

That's not a problem with MDB but with jsfiddle. Locally or in Codepen everything works.

maksam07 free commented 8 months ago

I noticed some bug in my development, I apologize for wasting my time, but you have motivated me to do more tests. Thank you.

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 6.4.2
  • Device: PC
  • Browser: Chrome
  • OS: Kubuntu
  • Provided sample code: No
  • Provided link: No