Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

demoskp's avatar

Modal is not a function - Laravel Spark

I realised that the notifications bell on the top does not trigger the notifications sidebar to open, the call it does is the following:

$('#modal-notifications').modal('show')

and it complain that "modal is not a function" I checked to see how bootstrap and jquery as loaded and if jquery is loaded before bootstrap and it does in the spark-bootstrap.js file. The issue I believe was there from the beginning.

Does anyone know what the issue is and why the function is not found?

0 likes
6 replies
michaeln's avatar

Are you able to interact in any other way with the #modal-notifications element? What happens if you try to console.log it?

demoskp's avatar

There is no need to console log it, I can access the element from the console hide it or show it like this:

$('#modal-notifications').css('display','block');

The issue is the way bootstrap and jquery are loaded and interact as modal function is a combination of bootstrap js and jquery.

michaeln's avatar

I didn't mean from the console directly. I meant from wherever you are getting the error. I have zero context for what you are trying to do, when you get an error message, etc.

demoskp's avatar

I explained at the top that this happens when trying to open the notifications sidebar in spark admin. Console logging something will not help. Do you have experience with laravel spark?

michaeln's avatar

Yep sorry it's just too vague. I can't see the error output or stack trace. Trying to console.log from in the code would indicate whether you had access to the object at all from that scope and how it sees the object from there. Do you have JavaScript experience?

You're literally sharing the bare minimum information. One line cut and paste from the source, and a vague error that could be caused for any number of reasons depending on how you went about customizing things. I'm assuming of course that you have run npm run dev on the machine you are getting error from.

demoskp's avatar
demoskp
OP
Best Answer
Level 2

I should have posted the fix to this issue a while back but here it is in case anyone comes across it again.

The issue was that the javascript library was loaded as a depedency through npm and also as a cdn link and thus they were conflicting. Issue was resolved once the cdn link to the library was removed

Please or to participate in this conversation.