Skip to content

Instantly share code, notes, and snippets.

@JKring
Last active December 24, 2015 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JKring/6845782 to your computer and use it in GitHub Desktop.
Save JKring/6845782 to your computer and use it in GitHub Desktop.
async photo uploading
<script type="text/javascript">
// You'll probably have to call this from $(document).ready because it requires the DOM to be loaded.
function bindToForm(){
$("#upload-photo-form").fileupload({
dataType: 'json',
progress: function() {
// Indicate that the upload has begun
},
done: function(e, data) {
// use data.id, data.name, and data.url to display the photo
}
});
};
</script>
<form action="events/upload_photo" id="upload-photo-form">
<input name="utf8" type="hidden" value="✓">
<input name="authenticity_token" type="hidden" value="<%= form_authenticity_token %>">
<input name="event_id" type="hidden" value="<%= @event.id %>">
<input name="file" type="file">
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment