Rails no recargará javascript local si se redirige desde un enlace de anclaje
Frecuentes
Visto 1,606 veces
2
Tengo un foo.js
de FoosController
. If I enter localhost:3000/foos, then the jquery onready function will be loaded. However, if I click on an <a href="/es/foos">
or link_to
, the jquery onready function won't be loaded. Is there a problem with my configuration? or is this an expected result.
2 Respuestas
4
I think the cause of your problem is turbolinks. Try to disable turbolinks or add a data-no-turbolink='true'
to your links and check if it works.
More about turbolink and document.ready aquí.
Respondido el 22 de Septiembre de 13 a las 22:09
0
run your code after turbolink:load event:
$( document ).on('turbolinks:load', () => {
// your code
});
Respondido 27 Feb 18, 02:02
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas javascript jquery ruby-on-rails or haz tu propia pregunta.