⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Autosave on Upload



xsigno
  • profile picture
  • Member

Posted 07 November 2011 - 23:26 PM

I think that a useful feature would be the autosave of the record when the user uploads a new file. This avoid to have tons of orphans files in the filesystem when the user forget to save the record.
I'm trying to reverse engeenering but there is no way to retrieve the record id after an upload. (without deep modifying all the functions chain)

lucaweb85
  • profile picture
  • Member

Posted 25 July 2012 - 10:58 AM

I add $("#crudForm").submit(); in assets/grocery_crud/js/jquery_plugins/config/jquery.fileupload.config.js

on


done: function (e, data) {
if(typeof data.result.success != 'undefined' && data.result.success)
{
$("#loading-"+unique_id).hide();
$("#progress-"+unique_id).html('');
$.each(data.result.files, function (index, file) {
$('#upload-state-message-'+unique_id).html('');
$("input[rel="+uploader_element.attr('name')+"]").val(file.name);
var file_name = file.name;
$('#file_'+unique_id).html(file_name);
$('#file_'+unique_id).attr('href',file.url);
$('#hidden_'+unique_id).val(file_name);
//$('#'+uploader_id).hide();
$('#success_'+unique_id).fadeIn('slow');
$('#delete_url_'+unique_id).attr('rel',file_name);
$('#upload-button-'+unique_id).slideUp('fast');
});
}
else if(typeof data.result.message != 'undefined')
{
alert(data.result.message);
show_upload_button(unique_id, uploader_element);
}
else
{
alert(error_on_uploading);
show_upload_button(unique_id, uploader_element);
}
// I ADD THIS HEAR//
$("#crudForm").submit();
},