jquery Datatables not formatted until browser refresh









up vote
0
down vote

favorite












I'm on Rails 5.2, MacOS 10.13.4, ruby 2.3.7p456. I am following this guide for implementing jquery datatables. Both in development and production, the tables load without datatable formatting, but after a browswer refresh, the tables display perfectly with the datatable formatting. I'm installing using the CDN.



Here is a screenshot on inital load:



enter image description here



Then after refresh:



enter image description here



My application.html.erb:



<head>

<%= csrf_meta_tags %>

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js"></script>




In my html the table has id = 'search'



the search.coffee file:



 $(document).ready ->
$('#search').DataTable()
return


and finally the application.js file:



//= require jquery3
//= require popper
//= require bootstrap
//= require rails-ujs
//= require jquery.turbolinks
//= require turbolinks
//= require_tree .


I have tried moving the CDN scripts from the application.html.erb to the show page, removing the load jquery script, and using different versions of jquery in the load jquery script. I've tried on Chrome Version 67.0.3396.79 and Safari Version 11.1. All of these resulted in no change.



Has anyone run into this? I saw this question: and tried adding gem 'jquery-turbolinks' to gemfile and adding //= require jquery.turbolinks to application.js, and after bundle install and restarting the server, still no change.










share|improve this question

























    up vote
    0
    down vote

    favorite












    I'm on Rails 5.2, MacOS 10.13.4, ruby 2.3.7p456. I am following this guide for implementing jquery datatables. Both in development and production, the tables load without datatable formatting, but after a browswer refresh, the tables display perfectly with the datatable formatting. I'm installing using the CDN.



    Here is a screenshot on inital load:



    enter image description here



    Then after refresh:



    enter image description here



    My application.html.erb:



    <head>

    <%= csrf_meta_tags %>

    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
    <script
    src="https://code.jquery.com/jquery-3.3.1.min.js"
    integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
    crossorigin="anonymous"></script>
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css">
    <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js"></script>




    In my html the table has id = 'search'



    the search.coffee file:



     $(document).ready ->
    $('#search').DataTable()
    return


    and finally the application.js file:



    //= require jquery3
    //= require popper
    //= require bootstrap
    //= require rails-ujs
    //= require jquery.turbolinks
    //= require turbolinks
    //= require_tree .


    I have tried moving the CDN scripts from the application.html.erb to the show page, removing the load jquery script, and using different versions of jquery in the load jquery script. I've tried on Chrome Version 67.0.3396.79 and Safari Version 11.1. All of these resulted in no change.



    Has anyone run into this? I saw this question: and tried adding gem 'jquery-turbolinks' to gemfile and adding //= require jquery.turbolinks to application.js, and after bundle install and restarting the server, still no change.










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm on Rails 5.2, MacOS 10.13.4, ruby 2.3.7p456. I am following this guide for implementing jquery datatables. Both in development and production, the tables load without datatable formatting, but after a browswer refresh, the tables display perfectly with the datatable formatting. I'm installing using the CDN.



      Here is a screenshot on inital load:



      enter image description here



      Then after refresh:



      enter image description here



      My application.html.erb:



      <head>

      <%= csrf_meta_tags %>

      <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
      <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
      <script
      src="https://code.jquery.com/jquery-3.3.1.min.js"
      integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
      crossorigin="anonymous"></script>
      <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css">
      <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js"></script>




      In my html the table has id = 'search'



      the search.coffee file:



       $(document).ready ->
      $('#search').DataTable()
      return


      and finally the application.js file:



      //= require jquery3
      //= require popper
      //= require bootstrap
      //= require rails-ujs
      //= require jquery.turbolinks
      //= require turbolinks
      //= require_tree .


      I have tried moving the CDN scripts from the application.html.erb to the show page, removing the load jquery script, and using different versions of jquery in the load jquery script. I've tried on Chrome Version 67.0.3396.79 and Safari Version 11.1. All of these resulted in no change.



      Has anyone run into this? I saw this question: and tried adding gem 'jquery-turbolinks' to gemfile and adding //= require jquery.turbolinks to application.js, and after bundle install and restarting the server, still no change.










      share|improve this question













      I'm on Rails 5.2, MacOS 10.13.4, ruby 2.3.7p456. I am following this guide for implementing jquery datatables. Both in development and production, the tables load without datatable formatting, but after a browswer refresh, the tables display perfectly with the datatable formatting. I'm installing using the CDN.



      Here is a screenshot on inital load:



      enter image description here



      Then after refresh:



      enter image description here



      My application.html.erb:



      <head>

      <%= csrf_meta_tags %>

      <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
      <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
      <script
      src="https://code.jquery.com/jquery-3.3.1.min.js"
      integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
      crossorigin="anonymous"></script>
      <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css">
      <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js"></script>




      In my html the table has id = 'search'



      the search.coffee file:



       $(document).ready ->
      $('#search').DataTable()
      return


      and finally the application.js file:



      //= require jquery3
      //= require popper
      //= require bootstrap
      //= require rails-ujs
      //= require jquery.turbolinks
      //= require turbolinks
      //= require_tree .


      I have tried moving the CDN scripts from the application.html.erb to the show page, removing the load jquery script, and using different versions of jquery in the load jquery script. I've tried on Chrome Version 67.0.3396.79 and Safari Version 11.1. All of these resulted in no change.



      Has anyone run into this? I saw this question: and tried adding gem 'jquery-turbolinks' to gemfile and adding //= require jquery.turbolinks to application.js, and after bundle install and restarting the server, still no change.







      datatables ruby-on-rails-5.2






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 12 at 14:05









      tomb

      776616




      776616






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote













          Responding on this from the answer over here - Rails 5: how to use $(document).ready() with turbo-links



          At some point the $(document).ready call was depreciated with turbolinks, try:



          $( document ).on('turbolinks:load', function() 
          console.log("It works on each visit!")
          )





          share|improve this answer



























            up vote
            0
            down vote



            accepted










            I completely removed turbolinks from my app in order to get the datatables to act properly.






            share|improve this answer




















              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50819170%2fjquery-datatables-not-formatted-until-browser-refresh%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              1
              down vote













              Responding on this from the answer over here - Rails 5: how to use $(document).ready() with turbo-links



              At some point the $(document).ready call was depreciated with turbolinks, try:



              $( document ).on('turbolinks:load', function() 
              console.log("It works on each visit!")
              )





              share|improve this answer
























                up vote
                1
                down vote













                Responding on this from the answer over here - Rails 5: how to use $(document).ready() with turbo-links



                At some point the $(document).ready call was depreciated with turbolinks, try:



                $( document ).on('turbolinks:load', function() 
                console.log("It works on each visit!")
                )





                share|improve this answer






















                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  Responding on this from the answer over here - Rails 5: how to use $(document).ready() with turbo-links



                  At some point the $(document).ready call was depreciated with turbolinks, try:



                  $( document ).on('turbolinks:load', function() 
                  console.log("It works on each visit!")
                  )





                  share|improve this answer












                  Responding on this from the answer over here - Rails 5: how to use $(document).ready() with turbo-links



                  At some point the $(document).ready call was depreciated with turbolinks, try:



                  $( document ).on('turbolinks:load', function() 
                  console.log("It works on each visit!")
                  )






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 11 at 15:32









                  patrickmult

                  313




                  313






















                      up vote
                      0
                      down vote



                      accepted










                      I completely removed turbolinks from my app in order to get the datatables to act properly.






                      share|improve this answer
























                        up vote
                        0
                        down vote



                        accepted










                        I completely removed turbolinks from my app in order to get the datatables to act properly.






                        share|improve this answer






















                          up vote
                          0
                          down vote



                          accepted







                          up vote
                          0
                          down vote



                          accepted






                          I completely removed turbolinks from my app in order to get the datatables to act properly.






                          share|improve this answer












                          I completely removed turbolinks from my app in order to get the datatables to act properly.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Sep 4 at 2:39









                          tomb

                          776616




                          776616



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50819170%2fjquery-datatables-not-formatted-until-browser-refresh%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Top Tejano songwriter Luis Silva dead of heart attack at 64

                              政党

                              天津地下鉄3号線