nikolay
nikolay

Reputation: 112

Rails - load javascript function every server/client action

My rails app load application.js functions only when im refresh the page,in other case (site surfing,AJAX operations) it doesent.So how to load application.js every server-client actions?Every function pulled inside the

 $(document).ready(function() {

Upvotes: 0

Views: 129

Answers (1)

tirdadc
tirdadc

Reputation: 4713

$(document).ready(function() { will not work properly with Turbolinks enabled since it'll be triggered just once, you want to use this instead:

var ready;
ready = function() {

  ...your javascript goes here...

};

$(document).ready(ready);
$(document).on('page:load', ready);

See this link for more information: Rails 4: how to use $(document).ready() with turbo-links

Upvotes: 1

Related Questions