DataTables javascript - RoR












0














I do not load the datatable when I change the page but if it does when I refresh it:



When I go to the page for the first time
enter image description here



When I go to see students
enter image description here



When he returned to the student page
enter image description here



My datatable js:



$(document).ready(function () {
$("#alumnos_table").dataTable({
destroy: true,
responsive: true,
"autoWidth": true,
"oLanguage": {
"sProcessing": "Procesando...",
"sLengthMenu": "Mostrar _MENU_ registros",
"sSearch": "",
"sZeroRecords": "No existen datos",
"sInfo": "Registro _START_ al _END_ de _TOTAL_ registros",
"sInfoEmpty": "Registro 0 al 0 de 0 registros",
"sLoadingRecords": "Cargando...",
"sInfoFiltered": "(Filtrado de _MAX_ registros)",
bDestroy: true,
paging: false,
searching: false,
"oPaginate": {
"sFirst": "Primero",
"sLast": "Último",
"sNext": "Siguiente",
"sPrevious": "Anterior"
},
"oAria": {
"sSortAscending": ": Activar para ordenar la columna de manera ascendente",
"sSortDescending": ": Activar para ordenar la columna de manera descendente"
}
},
"aoColumnDefs": [
{"bSortable": false, "aTargets": [7]}
],
bProcessing: true,
bServerSide: true,
"sAjaxSource": "/client/alumnos"
});
});


my routes:



namespace :client do
get "index" => "index#index"
resources :alumnos
resources :asignaturas
resources :carreras
end


my action index:



def index
respond_to do |format|
format.html
format.json {render json: AlumnosDataTable.new(view_context)}
end
end


Any ideas on how to solve this?










share|improve this question



























    0














    I do not load the datatable when I change the page but if it does when I refresh it:



    When I go to the page for the first time
    enter image description here



    When I go to see students
    enter image description here



    When he returned to the student page
    enter image description here



    My datatable js:



    $(document).ready(function () {
    $("#alumnos_table").dataTable({
    destroy: true,
    responsive: true,
    "autoWidth": true,
    "oLanguage": {
    "sProcessing": "Procesando...",
    "sLengthMenu": "Mostrar _MENU_ registros",
    "sSearch": "",
    "sZeroRecords": "No existen datos",
    "sInfo": "Registro _START_ al _END_ de _TOTAL_ registros",
    "sInfoEmpty": "Registro 0 al 0 de 0 registros",
    "sLoadingRecords": "Cargando...",
    "sInfoFiltered": "(Filtrado de _MAX_ registros)",
    bDestroy: true,
    paging: false,
    searching: false,
    "oPaginate": {
    "sFirst": "Primero",
    "sLast": "Último",
    "sNext": "Siguiente",
    "sPrevious": "Anterior"
    },
    "oAria": {
    "sSortAscending": ": Activar para ordenar la columna de manera ascendente",
    "sSortDescending": ": Activar para ordenar la columna de manera descendente"
    }
    },
    "aoColumnDefs": [
    {"bSortable": false, "aTargets": [7]}
    ],
    bProcessing: true,
    bServerSide: true,
    "sAjaxSource": "/client/alumnos"
    });
    });


    my routes:



    namespace :client do
    get "index" => "index#index"
    resources :alumnos
    resources :asignaturas
    resources :carreras
    end


    my action index:



    def index
    respond_to do |format|
    format.html
    format.json {render json: AlumnosDataTable.new(view_context)}
    end
    end


    Any ideas on how to solve this?










    share|improve this question

























      0












      0








      0







      I do not load the datatable when I change the page but if it does when I refresh it:



      When I go to the page for the first time
      enter image description here



      When I go to see students
      enter image description here



      When he returned to the student page
      enter image description here



      My datatable js:



      $(document).ready(function () {
      $("#alumnos_table").dataTable({
      destroy: true,
      responsive: true,
      "autoWidth": true,
      "oLanguage": {
      "sProcessing": "Procesando...",
      "sLengthMenu": "Mostrar _MENU_ registros",
      "sSearch": "",
      "sZeroRecords": "No existen datos",
      "sInfo": "Registro _START_ al _END_ de _TOTAL_ registros",
      "sInfoEmpty": "Registro 0 al 0 de 0 registros",
      "sLoadingRecords": "Cargando...",
      "sInfoFiltered": "(Filtrado de _MAX_ registros)",
      bDestroy: true,
      paging: false,
      searching: false,
      "oPaginate": {
      "sFirst": "Primero",
      "sLast": "Último",
      "sNext": "Siguiente",
      "sPrevious": "Anterior"
      },
      "oAria": {
      "sSortAscending": ": Activar para ordenar la columna de manera ascendente",
      "sSortDescending": ": Activar para ordenar la columna de manera descendente"
      }
      },
      "aoColumnDefs": [
      {"bSortable": false, "aTargets": [7]}
      ],
      bProcessing: true,
      bServerSide: true,
      "sAjaxSource": "/client/alumnos"
      });
      });


      my routes:



      namespace :client do
      get "index" => "index#index"
      resources :alumnos
      resources :asignaturas
      resources :carreras
      end


      my action index:



      def index
      respond_to do |format|
      format.html
      format.json {render json: AlumnosDataTable.new(view_context)}
      end
      end


      Any ideas on how to solve this?










      share|improve this question













      I do not load the datatable when I change the page but if it does when I refresh it:



      When I go to the page for the first time
      enter image description here



      When I go to see students
      enter image description here



      When he returned to the student page
      enter image description here



      My datatable js:



      $(document).ready(function () {
      $("#alumnos_table").dataTable({
      destroy: true,
      responsive: true,
      "autoWidth": true,
      "oLanguage": {
      "sProcessing": "Procesando...",
      "sLengthMenu": "Mostrar _MENU_ registros",
      "sSearch": "",
      "sZeroRecords": "No existen datos",
      "sInfo": "Registro _START_ al _END_ de _TOTAL_ registros",
      "sInfoEmpty": "Registro 0 al 0 de 0 registros",
      "sLoadingRecords": "Cargando...",
      "sInfoFiltered": "(Filtrado de _MAX_ registros)",
      bDestroy: true,
      paging: false,
      searching: false,
      "oPaginate": {
      "sFirst": "Primero",
      "sLast": "Último",
      "sNext": "Siguiente",
      "sPrevious": "Anterior"
      },
      "oAria": {
      "sSortAscending": ": Activar para ordenar la columna de manera ascendente",
      "sSortDescending": ": Activar para ordenar la columna de manera descendente"
      }
      },
      "aoColumnDefs": [
      {"bSortable": false, "aTargets": [7]}
      ],
      bProcessing: true,
      bServerSide: true,
      "sAjaxSource": "/client/alumnos"
      });
      });


      my routes:



      namespace :client do
      get "index" => "index#index"
      resources :alumnos
      resources :asignaturas
      resources :carreras
      end


      my action index:



      def index
      respond_to do |format|
      format.html
      format.json {render json: AlumnosDataTable.new(view_context)}
      end
      end


      Any ideas on how to solve this?







      javascript ruby-on-rails datatables






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 at 7:28









      AlexCs

      356




      356
























          2 Answers
          2






          active

          oldest

          votes


















          1














          If you're using turbolinks in your application, it might be the reason for it.



          Try replacing:



          $(document).ready(function () { 
          ....
          ....
          })


          With:



          document.addEventListener("turbolinks:load", function () {
          ....
          ....
          })


          or this:



          $(document).on('turbolinks:load', function() {
          ....
          });





          share|improve this answer























          • works perfect thank you very much
            – AlexCs
            Nov 20 at 23:16



















          1














          the code list above is a typical "Turbolinks" issue, you can either remove the "Turbolinks" from you project or you can load scripts like this



          $(document).on('turbolinks:load', function() {

          });


          You can see the documentation here Turbolinks.






          share|improve this answer





















          • It works very well, thanks for your help
            – AlexCs
            Nov 20 at 23:16











          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',
          autoActivateHeartbeat: false,
          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%2f53388161%2fdatatables-javascript-ror%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









          1














          If you're using turbolinks in your application, it might be the reason for it.



          Try replacing:



          $(document).ready(function () { 
          ....
          ....
          })


          With:



          document.addEventListener("turbolinks:load", function () {
          ....
          ....
          })


          or this:



          $(document).on('turbolinks:load', function() {
          ....
          });





          share|improve this answer























          • works perfect thank you very much
            – AlexCs
            Nov 20 at 23:16
















          1














          If you're using turbolinks in your application, it might be the reason for it.



          Try replacing:



          $(document).ready(function () { 
          ....
          ....
          })


          With:



          document.addEventListener("turbolinks:load", function () {
          ....
          ....
          })


          or this:



          $(document).on('turbolinks:load', function() {
          ....
          });





          share|improve this answer























          • works perfect thank you very much
            – AlexCs
            Nov 20 at 23:16














          1












          1








          1






          If you're using turbolinks in your application, it might be the reason for it.



          Try replacing:



          $(document).ready(function () { 
          ....
          ....
          })


          With:



          document.addEventListener("turbolinks:load", function () {
          ....
          ....
          })


          or this:



          $(document).on('turbolinks:load', function() {
          ....
          });





          share|improve this answer














          If you're using turbolinks in your application, it might be the reason for it.



          Try replacing:



          $(document).ready(function () { 
          ....
          ....
          })


          With:



          document.addEventListener("turbolinks:load", function () {
          ....
          ....
          })


          or this:



          $(document).on('turbolinks:load', function() {
          ....
          });






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 20 at 7:46

























          answered Nov 20 at 7:39









          Abhilash Reddy

          1,1301618




          1,1301618












          • works perfect thank you very much
            – AlexCs
            Nov 20 at 23:16


















          • works perfect thank you very much
            – AlexCs
            Nov 20 at 23:16
















          works perfect thank you very much
          – AlexCs
          Nov 20 at 23:16




          works perfect thank you very much
          – AlexCs
          Nov 20 at 23:16













          1














          the code list above is a typical "Turbolinks" issue, you can either remove the "Turbolinks" from you project or you can load scripts like this



          $(document).on('turbolinks:load', function() {

          });


          You can see the documentation here Turbolinks.






          share|improve this answer





















          • It works very well, thanks for your help
            – AlexCs
            Nov 20 at 23:16
















          1














          the code list above is a typical "Turbolinks" issue, you can either remove the "Turbolinks" from you project or you can load scripts like this



          $(document).on('turbolinks:load', function() {

          });


          You can see the documentation here Turbolinks.






          share|improve this answer





















          • It works very well, thanks for your help
            – AlexCs
            Nov 20 at 23:16














          1












          1








          1






          the code list above is a typical "Turbolinks" issue, you can either remove the "Turbolinks" from you project or you can load scripts like this



          $(document).on('turbolinks:load', function() {

          });


          You can see the documentation here Turbolinks.






          share|improve this answer












          the code list above is a typical "Turbolinks" issue, you can either remove the "Turbolinks" from you project or you can load scripts like this



          $(document).on('turbolinks:load', function() {

          });


          You can see the documentation here Turbolinks.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 at 8:05









          crazy_phage

          369420




          369420












          • It works very well, thanks for your help
            – AlexCs
            Nov 20 at 23:16


















          • It works very well, thanks for your help
            – AlexCs
            Nov 20 at 23:16
















          It works very well, thanks for your help
          – AlexCs
          Nov 20 at 23:16




          It works very well, thanks for your help
          – AlexCs
          Nov 20 at 23:16


















          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%2f53388161%2fdatatables-javascript-ror%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

          Costa Masnaga

          Fotorealismo

          Sidney Franklin