Disable Create button until after file upload is complete

Disable Create button until after file upload is complete

nuggetap3nuggetap3 Posts: 24Questions: 5Answers: 2

I have been looking through some of the forums, but I haven't quite found an answer to this question. I am having an issue with users that are uploading files, but they are not waiting until the upload is complete before they click the create button in the editor window. This is causing an issue where the attachment id is in one table, but the corresponding attachment is not in the attachment table. Which causes an error and does not allow the table to display any records. Is there a way to disable the create button during the file upload process?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,715Questions: 1Answers: 10,107 Site admin
    Answer ✓

    Interesting - I thought it actually did that automatically! I'll check into that.

    In the meantime you could do:

    var uploading = false;
    
    editor.on('preSubmit', function () {
      if (uploading) {
        return false;
      }
    });
    
    editor.on('preUpload', function () {
      uploading = true;
    });
    
    editor.on('postUpload', function () {
      uploading = false;
    });
    

    That will just use preSubmit to cancel the submit action based on the uploading variable we define and manipulate above.

    Allan

This discussion has been closed.