I have a modal in my page. When I try to call it when the windows load, it prints an error to the console that says :
$(...).modal is not a function
Causes for TypeError: $(…).modal is not a function:
Solutions:
In case, if a script attempt to access an element that hasn't been reached yet then you will get an error. Bootstrap depends on jQuery, so jQuery must be referenced first. So, you must be called the jquery.min.js and then bootstrap.min.js and further the bootstrap Modal error is actually the result of you not including bootstrap's javascript before calling the modal function. Modal is defined in bootstrap.js and not in jQuery. So the script should be included in this manner
In case if there are multiple instances of jQuery, the second jQuery
declaration prevents bootstrap.js from working correctly. so make use of
jQuery.noConflict();
before calling the modal popup
jQuery.noConflict();
$('#prizePopup').modal('show');
jQuery event aliases like .load
, .unload
or .error
deprecated since jQuery 1.8.
$(window).on('load', function(){
$('#prizePopup').modal('show');
});
OR try opening the modal popup directly
$('#prizePopup').on('shown.bs.modal', function () {
...
});