Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message of custom validation won't be displayed #936

Closed
5 of 6 tasks
Roluc opened this issue Apr 20, 2017 · 1 comment
Closed
5 of 6 tasks

Message of custom validation won't be displayed #936

Roluc opened this issue Apr 20, 2017 · 1 comment

Comments

@Roluc
Copy link

Roluc commented Apr 20, 2017

Prerequisites

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • The issue still exists against the latest master branch of bootstrap-fileinput.
  • This is not an usage question. I confirm having read the plugin documentation and demos.
  • This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
  • I have attempted to find the simplest possible steps to reproduce the issue.
  • I have included a failing test as a pull request (Optional).

Steps to reproduce the issue

  1. Added custom validation to 'filebatchpreupload' event (validation not needed to reproduce issue)
    this.element.on('filebatchpreupload', function(event, data, previewId, index) {
    return {
    message: "too many files!"
    };
    });
  2. As soon as the validation fails and uploads are cancelled, the issue happens on line 3140, saying 'self.ajaxAborted' is undefined.
  3. As far as i debugged the code, i encountered that self.ajaxAborted will be overwritten by the 'fileenable' event raised some lines above:
    -> 3138: self.cancel();
    -> 3247: self.unlock();
    -> 3218: self.enable();
    -> 3325: self._raise('fileenabled');
    -> 990: self.ajaxAborted = e.result;
    Undefined will be written into self.ajaxAborted.

So on line 3140 there wont be a message accessible anymore.
self._showUploadError(self.ajaxAborted.message, data, 'filecustomerror');

Therefore the custom error message won't be displayed.

A possible solution could be:

  • to move line 3138 after line 3140
    or
  • instead of using self.ajaxAborted.message, use data.abortMessage as a parameter for _showUploadError.

Libraries

  • jQuery version: 1.11.3
  • bootstrap-fileinput version: 4.4.0
@kartik-v
Copy link
Owner

Thanks for detailing the issue. Will check and update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants