This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Antonija
Antonija

I have menu that has

<li><a href="{{ 'home'|page }}" class="scroll">Contact</a></li>

And functon that triggers scroll to part where contact form is.


$(function(){
    $(".scroll").click(function(){
        $("html,body").animate({scrollTop:$("#contact").offset().top},"500");
        return false;
    });
    if (window.location.hash == "#contact") $(".scroll").trigger("click");
});

The problem is when I am on some other part of my website and click on Contact link it opens home page but never triggers that scroll. How can I make that everytime that link is clicked it opens home and scrolls or if on home page then just scrolls?

Last updated

pcampbellsoft
pcampbellsoft

I have a similar issue, and I've not tested this on my own site, but is it related to the event handler? Do you need to make it a dynamic selector?

$(body).on("click",".scroll", function (e) {
}

I guess it really depends where you are calling that function; whether it binds correctly.

Last updated

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.