[英]Parent and child event listener
I am creating a web page that uses bootstrap, jquery and inspinia template. 我正在创建一个使用引导程序,jquery和inspinia模板的网页。
I use 3 files namely index.html - Where I import all my scripts 我使用3个文件,即index.html-将所有脚本导入其中
<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 navigation.html-我的侧边栏在哪里headerFooter.html-侧边栏切换的按钮在哪里
inspinia.js - where the event listener is place inspinia.js-事件侦听器所在的位置
$('.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. 但是,如果所有div元素都在索引中而不使用
ng-include
则按钮将正确切换。
BTW: I am using bootstrap 3.xx 顺便说一句:我正在使用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. Angular在运行时插入您的HTML,因此您的jQuery代码一开始就不了解您的DOM。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.