Rails RJS file not calling Javascript code when an image is added but calls ruby code
===

I have a form where I am allowing a user to upload an image (it gets sent via ajax so its a remote form that allows image uploads).

So after the form is submitted it calls a js.rjs file. Now if an image was included none of the javascript in that file gets executed but if I have ruby code in it it does (but the image does get saved in the database and image is saved in the project.

But if the user did not add an image to the field everything works fine.

Here is some code:

    = simple_form_for(@equipment, :html => { :multipart => true }, :remote => true) do |f|
      = link_to_close new_equipment_path
      = f.hidden_field :user_id
      = hidden_field_tag "opportunity", "#{@opportunity.id if @opportunity}"

    = hook(:equipment_top_section, self, :f => f) do
    .section
    %table
      %tr
        %td
          .label.top.req #{t :name}:
          = f.text_field :name
        %td= spacer
        %td
          .label.top #{t :link}:
          = f.text_field :link
      %tr
        %td
          = f.input :age, :as => :integer
        %td= spacer
        %td
          .label #{t :assigned_to}:
          = owner_select(:equipment, @repositories, current_user)
      %tr
        %td
          / = f.hidden_field
        %td= spacer
        %td
          .label #{t :image}:
          = f.file_field :avatar

and the rjs file:


    if @equipment.valid?
      page.call "crm.al"
      puts 'in the createjs'
      puts @equipment
      page[:create_equipment_arrow].replace_html "&#9658;"
      page[:create_equipment_title].replace_html t(:equipment)
    .... and some more here ...
    end
