user2513971
user2513971

Reputation:

jQuery load only once

I try to do some jQuery scripts on my rails project. I'm very beginner in both so i have many problems... Right now i dont know how to load jQuery not only once. If i understand, jQuery in rails is loading only once in header - so it works only on first visit? Because when i click for example on logo - that has link_to root_path - jQuery stop working. My jQuery code:

$(document).ready(function() {
    $('.tooltip').tooltipster({
    animation: 'grow'
});
});

It works when only on reload. What should i do to make this works after clicking on link_to root_path - its stay on that same page but jQuery stop working.

Upvotes: 1

Views: 477

Answers (1)

revolver
revolver

Reputation: 2405

I suspect you are using turbolink. Some info of Turbolink on railcasts.

$(document).on("ready page:change", function() {
    $('.tooltip').tooltipster({
        animation: 'grow'
    });
});

Upvotes: 4

Related Questions