I don't really know how to formulate this but I have this jquery code that enables me to scroll smoothly on a click on an anchor.
$(function() {
$('a.page-scroll').bind('click', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1500, 'easeInOutExpo');
event.preventDefault();
});
});
But when the page where the code is hosted is loaded via ajax, it no longer enables the smooth scroll. To fix it I added body to the code yet not scrolling.
$(function() {
$('body a.page-scroll').bind('click', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1500, 'easeInOutExpo');
event.preventDefault();
});
});
Please how can I keep scrollable working even when a page is loaded via ajax ?