Bootstrap - Modal Dialog - TypeError
In one of my ASP.Net MVC project, I had a JavaScript function that launches a bootstrap modal dialog. Every time the function is called, it kept throwing an error -
Function Call - $("#Somediv").modal('show')
Error - Uncaught TypeError: undefined is not a function
Of course, I checked, double checked & tried modifying the code, yet it kept failing. Taking the clue from the error ("not a function"), I started poking around the project looking for jQuery & Bootstrap files that are being loaded to explore the possibility that modal is not recognized as a function.
Luckily, I was on the right track and it ended up being a file linking error as I was loading the jQuery & Bootstrap files twice - once part of the bundle & another using the script tag on the shared layout view. I have added the script tags for testing purposes & forgot to remove them. This was causing the files to load out of sync as jQuery has to be loaded before bootstrap for it to work!
Labels: ASP.NET, ASP.NET MVC 4, Bootstrap, Dialog Box, Error, Function, Javascript, jQuery, Modal, MVC, TypeError, UnCaught, undefined, undefined is not a function
1 Comments:
Thanks. Resolved same issue with your post.
6:22 AM
Post a Comment
Subscribe to Post Comments [Atom]