DataTables javascript - RoR
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
When I go to see students
When he returned to the student page
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
add a comment |
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
When I go to see students
When he returned to the student page
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
add a comment |
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
When I go to see students
When he returned to the student page
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
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
When I go to see students
When he returned to the student page
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
javascript ruby-on-rails datatables
asked Nov 20 at 7:28
AlexCs
356
356
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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() {
....
});
works perfect thank you very much
– AlexCs
Nov 20 at 23:16
add a comment |
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.
It works very well, thanks for your help
– AlexCs
Nov 20 at 23:16
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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() {
....
});
works perfect thank you very much
– AlexCs
Nov 20 at 23:16
add a comment |
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() {
....
});
works perfect thank you very much
– AlexCs
Nov 20 at 23:16
add a comment |
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() {
....
});
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() {
....
});
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
add a comment |
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
add a comment |
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.
It works very well, thanks for your help
– AlexCs
Nov 20 at 23:16
add a comment |
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.
It works very well, thanks for your help
– AlexCs
Nov 20 at 23:16
add a comment |
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.
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.
answered Nov 20 at 8:05
crazy_phage
369420
369420
It works very well, thanks for your help
– AlexCs
Nov 20 at 23:16
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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