Topic: MDB5 Alert throws error if called by JS

jczeledonp free asked 3 years ago


Expected behavior

mdb.Alert.getInstance(document.getElementById('show-example')).show();

Actual behavior

Firefox: Uncaught TypeError: can't access property "show", mdb.Alert.getInstance(...) is undefined

Chrome: Uncaught TypeError: Cannot read property 'show' of null

Resources (screenshots, code snippets etc.) I'm using MDB5 PRO 3.3 version. Also tried with new MDB5 3.4 version but it comes with mdb.min.js 3.3.0 , NOT 3.4.0.

In your website works with 3.4, not with older versions. But I can't get the mdb.min.js 3.4.0 version


Grzegorz Bujański staff commented 3 years ago

Check out my example: https://mdbootstrap.com/snippets/standard/grzegorz-bujanski/2946212#html-tab-view

It works fine. Can you send your example which causes this error?


cfuller free answered 2 years ago


I am having the same issue on my site, were you ever able to find a resolution. When I use the exact code that is recommended on the mdb builder site, I still get the error, when I do the mdb.Alert.getInstance(document.getElementById("alertExample")) JS command, it is returning as null. Thanks!


Dawid Wajszczuk staff commented 2 years ago

Hi. Can you provide more information about you issue (maybe links or a snippet with code that causes problems)? Also which version of MDB are you using? Here is the snippet with MDB 3.7.1 and I don't see such errors https://mdbootstrap.com/snippets/standard/d-wajszczuk/3116003#html-tab-view.


Michał Duszak staff commented 2 years ago

This issue has continuation in the new topic: https://mdbootstrap.com/support/standard/alert-on-item-brought-in-through-ajax-result/



Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: 3.2.0
  • Device: Laptop
  • Browser: Chrome, Firefox
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No
Tags