Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

125
Vistas
Load Javascript File for Ajax (js.erb)

For my current design, I have 3 menus that load different content, so I decided to use Ajax render and js.erb files.

An example of this:

controller:

def my_route
  respond_to do |format|
    format.js
  end
end

my_route.js.erb:

$('#content').html("<%= j render 'my_route_partial' %>");

This loads my page, but in the main_page which loads the three Ajax content, I have:

<% content_for :javascripts do %>
  <%= include_javascript_tag 'my_javascript_file' %>
<% end %>

This loads the javascript related to the main page, but it does not load the javascript that should work with any of the pages loaded through Ajax afterwards.

I have also tried to just include the javascript tag into the files, but it didn't work. I don't want to leave the javascript code into the js.erb file, so is there any way to do it?

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda