I have some code that lets me scroll up the page. The problem is that one of my classes creates the upward scroll, but then when i manually try to scroll down the page, it scrolls back up a few times! Is it common? How do i fix this?
a snippet from my php code
$links .= '<a href="#!" class="sidenav-link" default-rel="'.$default_rel.'" rel="'.$rel.'"><i class="fa fa-'.$new_v['icon'].'"></i> '.$new_v['subheader_name'].'</a>';
And here is my jquery function that gets content from a page
function toggleContent(selector, event)
{
var queryString = createQueryString(selector);
$.ajax({
url: 'ajaxLoad.php?'+queryString,
method: 'GET',
success: function(response) {
$("#page-wrapper .container-fluid").html(response.html);
eval($(response.js).text());
//optional msg
var information = $(selector).attr("information");
var danger = $(selector).attr("danger");
if (!information == "")
{
displayInformation(information);
}
if (!danger == "")
{
displayDanger(danger);
}
//reset msg
$(selector).attr("information","");
$(selector).attr("danger","");
// run specific code
if (typeof runSpecific == 'function')
{
runSpecific(selector, event);
}
// scroll up
$(".btn, .list-group-item, .sidenav-link").on("click",function(){
$("html, body").animate({ scrollTop: 0}, 300);
});
}
});
// reset rel
$(selector).attr('rel', $(selector).attr('default-rel') );
}
Note that .btn and .list-group-item do not create this issue, only the .sidenav-link.