Adminlte: Modal not working giving an error modal is not a function

Created on 16 Sep 2015  Â·  19Comments  Â·  Source: ColorlibHQ/AdminLTE

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

JS file included are:

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

question

Most helpful comment

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

All 19 comments

I don't think this has anything to do with AdminLTE framework. Make sure you are using right version of JQuery.
https://jsfiddle.net/zbexhxuk/

I tried your code on jsfiddle and it seems to be working fine.

I have included all the necessary JS files.

<!-- jQuery 2.1.4 -->
<script src="./resources/plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- Bootstrap 3.3.4 JS -->
<script src="./resources/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>

yes. The code works on JS fiddle but is not working when I deploy it.

Thanks,

Kumar

Did you solve this problem?

Has this been solved ? This is very important

same issue it took my hold day but still not resolved please help.
TypeError: $(...).modal is not a function
very serious issue unable to use model via ajaxmodelpopup and also via jquery above method.
waiting for solution.
big issue in adminlte.

+1

Is there any solution for this issue? My project is on Angular5.

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

I tried this one already but it didn't work out for me. So I moved to a
different solution which was overriding the CSS.

On Thu, Feb 8, 2018 at 6:05 PM, Sandeep Kumar notifications@github.com
wrote:

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 https://github.com/riyagloify
It worked! hope this will help. I'm also working on Angular5

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/almasaeed2010/AdminLTE/issues/685#issuecomment-364098394,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AeJWAPBS1O8oZLPNzh2_LkAw0nRVPqnQks5tSun5gaJpZM4F-sob
.

--
Thanks,
Riya Khandelwal

I had been running into the same problem when I placed the JQuery in a filename.Js. I resolved this by placing $('#modalPopup').modal(options); at the bottom of the HTML. I think this can also be solved by placing the link to your Js file below Bootstrap links which a little undesirable but worth trying.

I'am also having the same error. I'am using scripts in layout.handlebars (I am using node.js to serve it)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"> </script> <!-- <script src="https://apis.google.com/js/platform.js" async defer></script> --> <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBAj8K9Mikc3UunoY2qUaPt3tueavlGkkA&callback=initMap" async defer></script> <script src="javascripts/arKirtasiye.js"></script>
I'am adding dynamic elements in javascript file which is:
$(".content").append("<div class='ccategoryitem' id='cci" + categoryitems[i]._id + "' data-toggle='modal' data-target='itemModal'> " + "<img src='/images/categoryitem/" + categoryitems[i].photoID + ".jpg' title='" + categoryitems[i].itemName +"'> <p class='imagetext'>"+ categoryitems[i].itemName +"</p></div> ")
myModal is:
`

@sbilgil Maybe try and not post your google maps Key in the open like that.

its because the jquery you are using doesnot support ajax anyore, its possible you're using slim jquery..
replace it with:

I change from

$("#modal_id").modal("show");

To
window.$("#modal_id").modal("show"); It's work for me.

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

It is worked bro!!!!
thanks a lot...
i have tried many ways to tackle the problem...but you answer did it...

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

Man, you're great. That worked for me..

I change from

$("#modal_id").modal("show");

To
window.$("#modal_id").modal("show"); It's work for me.

Exactly right

@Chanty-SOK Your solution actually worked for me. I am using nuxt.js

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

It worked thanks!

Was this page helpful?
0 / 5 - 0 ratings