Modal not working giving an error modal is not a function

See original GitHub issue

I am getting an error in browser debugger " TypeError: $(…).modal is not a function"

JS file included are:

<script src="./resources/plugins/jQuery/jQuery-2.1.4.min.js"></script> <script src="./resources/plugins/jQueryUI/jquery-ui.min.js" type="text/javascript"></script> <script src="./resources/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>

all the files included without an error.

I am calling the modal as follows

var options = {
        "backdrop" : "static",
        "show":true
    }
$('#modalPopup').modal(options);

The model html is as follows:

    <div class="modal fade" id ="modalPopup" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h4 class="modal-title">Modal title</h4>
          </div>
          <div class="modal-body">
            <p>One fine body</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Save changes</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <!-- ============= info popup ============= -->

I am trying to figure out what I am doing wring? Can anyone help?

Thanks in advance,

Kumar

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:19 (1 by maintainers)

github_iconTop GitHub Comments

42reactions
Chanty-SOKcommented, Sep 13, 2019

I change from

$(“#modal_id”).modal(“show”);

To window.$(“#modal_id”).modal(“show”); It’s work for me.

24reactions
SKrudracommented, Feb 8, 2018

I was also running into the same issue for a couple of days, finally, I changed the import statement of jQuery from: import * as $ from ‘jquery’;

to: declare var $ : any;

@riyagloify It worked! hope this will help. I’m also working on Angular5

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: $(...).modal is not a function with bootstrap Modal
This error is actually the result of you not including bootstrap's javascript before calling the modal function. Modal is defined in ...
Read more >
Possible solution for error - Bootstrap modal: is not a function
The $(…).modal is not a function is usually caused because scripts are loaded in the wrong order . The browser will execute the...
Read more >
Uncaught TypeError: $(...).modal is not a function - jQuery Forum
I put $ in watcher and i did not find any modal function there, what should i do? I am using jquery v3.2.1....
Read more >
$('#flash-overlay-modal').modal is not a function. - jQuery not ...
$('#flash-overlay-modal').modal is not a function. - jQuery not loading on safari ; src · "https://code.jquery.com/jquery-3.5.1.slim.min.js" ; integrity · "sha384- ...
Read more >
Bootstrap modal is not a function | Edureka Community
Bootstrap modal is not a function ... When I call my model in windows it gives an error to the console. ... How...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found