Created
June 6, 2015 05:49
-
-
Save brijeshgpt7/49ecc9d658e1435219e6 to your computer and use it in GitHub Desktop.
nested form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.amooma.de/screencasts/2015-01-22-nested_forms-rails-4.2/ |
Author
brijeshgpt7
commented
Jun 6, 2015
<script>
$('#file_<%=image%>').on('change', function () {
var filename = $('#file_<%=image%>').val();
alert($('#image<%=image%>').serialize());
$.ajax({
type: 'POST',
beforeSend: function (xhr) {
xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))
},
url: '/listings/document',
data: $('#image<%=image%>').serialize(),
success: function (data) {
$("#img-uploaded").html(data);
}
});
});
```
</script>
Edit image
<li>
</li>
</ul>
</div>
<div class="weblinks">
<div><span><label>Edit Youtube</label></span> <span>
<%=text_field_tag :web_link%><a href="#"><i class="fa fa-youtube-play"></i></a></span></div>
<div><span><label>Edit Youtube</label></span> <span>
<%=text_field_tag :web_link%><a href="#"><i class="fa fa-globe"></i></a></span></div>
</div>
</div>
<div class="imageanddocument-right">
<h4>Lorem Ipsum is simply dummy text</h4>
<div>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
<%= form_for Document.new ,:url => document_upload_listings_path, :html => { :id => "image",:multipart => true } do |form| %>
<%= form.file_field :avatar,multiple: true %>
<%= form.hidden_field :listing_id , :value => @list.id %>
<%#= form.submit("Save") %>
<%= form.submit "Save", id: "button_id" %>
<% end %>
</div>
Edit Document
<li>
</li>
</ul>
</div>
<div class="edit-actions">
<button class="cancel-button" type="button">Cancel</button>
<button class="save-button" type="button" id="myButton">Save</button>
</div>
</div>
<div class="imageanddocument-right">
<h4>Lorem Ipsum is simply dummy text</h4>
<div>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
<%= form_for Document.new ,:url => document_upload_listings_path, :html => { :id=>"document",:multipart => true } do |form| %>
<%= form.file_field :avatar,multiple: true %>
<%= form.hidden_field :listing_id , :value => @list.id %>
<%= form.submit "Save", id: "doc_button_id" %>
<% end %>
</div>
<img src="<%= asset_path File.extname(image.avatar_file_name)== ".pdf" ? "pdf.png" %>" >
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment