I get the following error when i try to call something related to bootstrap modals from custom javascript file: CLICK HERE FOR IMAGE
My index.php:
<?php
require "includes/header.php";
require "includes/navigacija.php";
?>
<div class="modal fade" tabindex="-1" role="dialog" id="dodajVraboten">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title"><span class="glyphicon glyphicon-plus-sign"></span> Додај вработен</h4>
</div>
<!-- MODAL CONTENT -->
</div>
</div>
</div>
<?php
require "includes/footer.php";
?>
My footer.php where jquery is included:
<script type="text/javascript" src="js/jquery-3.2.1.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/fastclick.js"></script>
<script type="text/javascript" src="js/skripti.js"></script>
<script type="text/javascript" src="js/postavki.js"></script>
</body>
</html>
I get the error when i run this code in postavki.js:
$(document).ready(function() {
$('#dodajVraboten').modal('show');
});
As you can see i load first jquery then bootstrap then my custom js file (postavki.js) where i'm getting that error. Also i have read that if i'm loading jquery multiple times i can get this error, but that's not the issue because i'm loading it only in header.php
If you can't open the image here is the error:
postavki.js:18 Uncaught TypeError: $(...).modal is not a function
at HTMLDocument.<anonymous> (postavki.js:18)
at fire (datatables.js:3199)
at Object.fireWith [as resolveWith] (datatables.js:3329)
at Function.ready (datatables.js:3548)
at HTMLDocument.completed (datatables.js:3564)
Thank you in advance.
EDIT (IF header.php is making any difference):
<!DOCTYPE html>
<html lang="mk">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>asd</title>
<link rel="icon" href="sliki/favicon.ico" type="image/x-icon"/>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/font-awesome.css" rel="stylesheet">
<link href="css/normalize.css" rel="stylesheet">
<link href="css/stil.css" rel="stylesheet" type="text/css">
</head>
<body>