upload File
upload File
I have a problem with the upload file
and submit()
function. After the successfully upload the submit should send all editor fields to update the database. The Problem is, that the file id are not send with the submit function to the server. If i do not automatically send the form with the submit() function ( click on the Form button) the file id would be send to the server.
the form field:
{
label: 'ranking.csv:',
name: 'fileId',
type: 'upload',
dragDrop: true,
clearText: 'Remove file',
display: function( fileId ) {
console.log( eEdit.file( 'paevent', fileId ).fileName );
return eEdit.file( 'paevent', fileId ).fileName;
}
}
hier my part
eEdit.on( 'postCreate postEdit postRemove uploadXhrSuccess', function( event, data ) {
if( 'uploadXhrSuccess' == event.type ) {
this.submit();
} else {
paevent.ajax.reload( null, false );
}
} );
the server sends after the upload request following json string:
{"files":{"paevent":{"15":{"filename":"lm-salzburg-rd1.xlsx","web_path":"\/files\/lm-salzburg-rd1.xlsx"}}},"upload":{"id":15}}
Where is my problem?
Andreas
Answers
The
upload.XhrSuccess
is triggered too early - it is fired off when the file upload is completed and before the returned data has been processed by Editor. Instead try listening forupload.editor
. It doesn't bubble though, so you would need to listen on theinput
element, which you can get withfield().input()
.Regards,
Allan
I did not understand the second part of your messages. I should listen on the input field, but where should I do this?
Allan