javascript - Ruby on Rails - Getting datatables to load 100% of time and not just on refresh -
my ruby on rails application has datatables; however, appear after user goes page , refreshes once. doesn't appear when go page.
here javascript that's run prior page loading (because it's before html content);
(function() { jquery(function() { homecoming $('#items').datatable(); }); }).call(this); however, thought using may help, didn't:
$(document).ready(function() { $('#items').datatable(); }); any suggestions on how accomplish goal easily?
whenever happens me, find culprit turbolinks. should able utilize 1 of 2 options around it.
the first workaround js has been passed around quite bit.
var ready; ready = function(){ //your js scripts go here }; $(document).ready(ready); $(document).on('page:load', ready); or can update link_to helper using page skip turbolinks when loading page:
<%= link_to "where you're going", add_product_path, data: { no_turbolink: true } %> javascript jquery ruby-on-rails
No comments:
Post a Comment