Note that there are some explanatory texts on larger screens.

plurals
  1. POCapturing rails form submit url with javascript
    primarykey
    data
    text
    <p>I'm using a rails form to submit an image to a carrierwave uploader.</p> <pre><code>&lt;p class="sidebar-title"&gt;UPLOAD IMAGE&lt;/p&gt; &lt;%= form_for :page_image, :url =&gt; {:controller =&gt; :menus, :action =&gt; :create_image}, :html =&gt; {:multipart =&gt; true, :id =&gt; "image-upload-form"} do |f| %&gt; &lt;ul&gt; &lt;li class="sub-heading"&gt;Choose Image&lt;/li&gt; &lt;li&gt;&lt;%= f.file_field :image %&gt;&lt;/li&gt; &lt;li class="sub-heading" style="text-align: center; width:50%; margin: 1.5em 25%"&gt;OR&lt;br&gt;&lt;/li&gt; &lt;li class="sub-heading"&gt;Image URL&lt;/li&gt; &lt;li&gt;&lt;%= f.text_field :remote_image_url %&gt;&lt;/li&gt;&lt;/ul&gt; &lt;ul&gt; &lt;li class="description"&gt;&lt;%= f.radio_button :authored, "true" %&gt; &lt;%= f.label :authored, "I am the author of this image and give permission for Gastromica to use it.", :value =&gt; "true" %&gt;&lt;/li&gt; &lt;li class="description"&gt;&lt;%= f.radio_button :authored, "false" %&gt; &lt;%= f.label :authored, "This image is licenced to be freely be used and shared cormercially. If attribution is required please type a url in the box below.", :value =&gt; "false" %&gt;&lt;/li&gt; &lt;li class="sub-heading"&gt;Attribution / Source URL&lt;/li&gt; &lt;li&gt;&lt;%= f.text_field :attribution %&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt; &lt;%= f.hidden_field :user_id, :value =&gt; "1" %&gt; &lt;% @attributes.each do |attr| %&gt; &lt;%= hidden_field_tag attr[0], attr[1]%&gt; &lt;% end %&gt; &lt;li&gt;&lt;%= f.submit "Submit Image", :class =&gt; "image-upload" %&gt;&lt;/li&gt; &lt;% end %&gt; </code></pre> <p>Because the user is uploading an image I would like to display. Something that just says the upload is in progress. So wrote the following javascript for that:</p> <pre><code>('.image-upload').click(function() { $(this).parents('.content').html('&lt;p class="description" &gt;Please wait, currrently uploading image...&lt;/p&gt;') }); </code></pre> <p>This works perfectly well in Safari but in any other browser it prevents the form submission from taking place and the image never uploads. Everything also seems to be running fine without the script in all browsers. Is there a way I can capture the submit form url and force it to submit after I display the image loading message?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload