I'm using a template that I bought. If I click on a link to go to another page, the javascript is not executed again. That's a big problem since there are a lot of things happening in these js.
I don't know for what reason but the only time it's working is when I click on the nav menu. Maybe it's because the nav bar has an ID and is used in the js file.
Here is a simplified version of my main.js:
(function($) {
var $window = $(window),
$body = $('body'),
$header = $('#header');
//...//
// Play initial animations on page load.
$window.on('load', function() {
window.setTimeout(function() {
$body.removeClass('is-preload');
}, 100);
});
// Dropdowns.
$('#nav > ul').dropotron({
alignment: 'center'
});
// Off-Canvas Navigation.
// Navigation Panel Toggle.
$('<a href="#navPanel" class="navPanelToggle">Menu</a>')
.appendTo($header);
// Navigation Panel.
$(
'<div id="navPanel">' +
'<nav>' +
$('#nav').navList() +
'</nav>' +
'<a href="#navPanel" class="close"></a>' +
'</div>'
)
.appendTo($body)
.panel({
delay: 500,
hideOnClick: true,
hideOnSwipe: true,
resetScroll: true,
resetForms: true,
side: 'right',
target: $body,
visibleClass: 'is-menu-visible'
});
})(jQuery);
And I just put it in my App.razor file:
<body class="is-preload">
<!-- Wrapper -->
<div id="wrapper">
<Routes />
</div>
<script src="_framework/blazor.web.js"></script>
<!-- Scripts -->
<script src="template/js/jquery.min.js"></script>
<script src="template/js/jquery.dropotron.min.js"></script>
<script src="template/js/browser.min.js"></script>
<script src="template/js/breakpoints.min.js"></script>
<script src="template/js/util.js"></script>
<script src="template/js/main.js"></script>
</body>
Can you help me. Thank you!