Reputation: 355
I am having trouble with a form input field. There is no real rhyme to its reason it happens sometimes on full page reload ie clicking the browser refresh. I can get it to work if I click on another link in the page and then another link back to the original address, or simply clicking a direct link to the current/same page.
Usually when its turbolinks you need to add ..on.('turbolinks:load', function
but its just a form field which is handled by turboliinks already, so its really confusing me.
This is the html when the button is functioning
<input name="commit" value="Post" id="formsubmit" data-disable-with="Create Micropost" type="submit">
and when it is not functioning it has disabled=""
<input name="commit" value="Post" id="formsubmit" data-disable-with="Create Micropost" disabled="" type="submit">
The input fields have some turbolinks jquery attached to them but its the same both situations. Its not the table dimension thing either when you put your form inside a <td>
tag. I really cant figure it out?
I can post my form details but its seems the same as my other forms. No errors in the server except for unpermitted parameter picture_cache
but dont think thats it.
Edit: Here is the form code
<section class="micropost_form">
<%= form_for(@micropost, remote: true) do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<%= gravatar_for(current_user, size: 30) %>
<div class="field">
<%= f.text_area :content, placeholder: "Compose new post..." %>
</div>
<div class="btn-file">
<label for="micropost_picture" onclick="showBrowseInput()">Choose File</label>
<%= f.file_field :picture, accept: 'image/jpeg,image/gif,image/png' %>
<%= f.hidden_field :picture_cache, :value => f.object.picture_cache %>
<button class="imagelinkbtn" type="button" onclick="showImageInput()">Image Link</button>
<button class="videolinkbtn" type="button" onclick="showVideoInput()">Embed Video</button>
<button class="giflinkbtn" type="button" onclick="showGifInput()">Embed Gif</button>
</div>
<div class="media_field_1">
Image <%= f.text_field :image_url %>
</div>
<div class="media_field_2">
Video <%= f.text_field :video_url, class: 'form-control' %>
</div>
<div class="media_field_3">
Gif <%= f.text_field :gif_url %>
</div>
<div class="thumb">
<% if f.object.picture.url.present? %>
<%= image_tag f.object.picture.url %>
<% end %>
</div>
<div class="media-preview" style='position:relative;height:300px'>
</div>
<%= f.submit value: "Post", id: "formsubmit" %>
<% end %>
<%= javascript_include_tag "media_preview_script" %>
<%= javascript_include_tag "picture_file_upload_size_limit" %>
</section>
Upvotes: 0
Views: 56
Reputation: 2675
Try this
Turn off autocomplete in form
= form_for @user, html: { autocomplete: "off" } do |f|
Upvotes: 1