Javascript no se ejecuta desde la confirmación posterior de remotipart

I'm a newb RoR programmer and I'm currently trying to make my js work after I upload a file using remotipart and submitting it with a POST request to the controller. Basically, after the button submit is clicked, the POST request is successfully sent but the parse_bond_file.js.erb is initiated as OTHER not as SCRIPT. Here is my code:

---upload.html.erb###

<%= form_for :parse_bond, :url => parse_bond_file_issuers_path, :html => { :multipart => true, :method => :post }, :remote => true do |f| %>
    <%= f.file_field :csv %>
    <%= f.submit 'Parse'%>
<% end %>

---issuer_controller.rb---

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

---parse_bond_file.js.erb---

alert('hello world!');

Por favor ayuda. ¡Gracias!

preguntado el 01 de febrero de 12 a las 03:02

I have the same issue. Did you find anything? -

2 Respuestas

With the latest remotipart, you need to wrap it in

<%= remotipart_response do %>
  console.log('hellow world!');
<% end %>

Respondido 18 Feb 13, 10:02

You need to add this line into your app/views/layouts/application.html.erb

<%= javascript_include_tag "application" %>

Respondido 18 Jul 13, 14:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.