Forums

scroll to top of form broken in J3.4

jcalvert 20 Jan, 2016
The solution that I came up with and used for Joomla 2.5 in this post...

https://www.chronoengine.com/forums/posts/f2/t98455.html?page=2

no longer works as I have upgraded the site to Joomla 3.4.8.

This code:

$(document).ready(function() {
function scrollToAnchor(aid){
    var aTag = $("a[name='"+ aid +"']");
    $('html,body').animate({scrollTop: aTag.offset().top},'slow');
}
scrollToAnchor('myform');
});


... no longer works to scroll the page after the form is submitted. I would like to scroll to the top of the form after the form is submitted. The anchor, "myform", is there... the code just doesn't work. Any ideas? It's like JQuery is disabled or there is some conflict, but I'm at a loss to determine why.

thanks,
JC
jcalvert 20 Jan, 2016
Another strange thing is that it takes over 1 minute to open the form with the "LOADING" circle going.

This same form opened in about 6 seconds on Joomla 2.5.

Maybe I should just delete the form (backup first) and reload it from the copy I exported from Joomla 2.5?
jcalvert 20 Jan, 2016
Answer
Problem solved. Joomla 3.4 has its own jQuery loaded which is in "no conflict" mode, meaning that jQuery code must begin with "jQuery", not "$". Here is my code converted to "no conflict" syntax:

<script type="text/javascript">
jQuery(document).ready(function() {
    function scrollToAnchor(aid){
    var aTag = jQuery("a[name='"+ aid +"']");
    jQuery('html,body').animate({scrollTop: aTag.offset().top},'slow');
}
scrollToAnchor('myform');
});
</script>


JC
This topic is locked and no more replies can be posted.