I am creating a web page that uses bootstrap, jquery and inspinia template.
I use 3 files namely index.html - Where I import all my scripts
<body ng-controller="MainCtrl" class="">
<div id="wrapper">
<div ng-include="'/app/components/navigation/navigation.html'"></div>
<div ng-include="'/app/components/header and footer/headerFooter.html'"></div>
</div>
</body>
<!-- JS -->
<script type="text/javascript" src="./assets/node_modules/jquery/dist/jquery.js"></script>
<script src="./assets/js/inspinia.js"></script>
<script type="text/javascript" src="./assets/node_modules/angular/angular.js"></script>
<script type="text/javascript" src="./assets/node_modules/bootstrap/dist/js/bootstrap.js"></script>
navigation.html - Where my side bar is in place headerFooter.html - Where the button for sidebar toggle is place
inspinia.js - where the event listener is place
$('.navbar-minimalize').on("click", function (event) {
$("body").toggleClass("mini-navbar");
SmoothlyMenu();
});
The question is, Why does whenever I press the button the side-bar doesn't turn into mini-navbar (class not applying) is this kind of setup.
but if all the div element is in index and not using ng-include
the button is toggling properly.
BTW: I am using bootstrap 3.xx
Change:
$('.navbar-minimalize').on('click, function() {});
to:
$('body').on('click', '.navbar-minimalize', function() {});
Angular insert your HTML at runtime, so your jQuery code doesn't know about your DOM on start.