3

I am looking for a way to reset the file selection, in case the user choose an invalid file for instance.

From this issue on gitHub, it appears that you need to unbind the event in order to reset the file selection, now, how do I do such a thing in AngularJS?

Markup:

<form name="applyForm" data-file-upload="model.uploadOptionsResume" action="{{model.application_url}}" method="{{model.method}}" enctype="multipart/form-data">
   <fieldset>
     <input type="file" data-ng-model='model.formData.resume' name="resume" data-ng-disabled="" data-valid-file data-my-validate data-value-required="true">
     <submit data-ng-disabled="applyForm.$invalid || innerLoader" class="btn btn-primary" style="width:99%;"  data-ng-click="submit(); model.submitFormApplicant()">
                            Apply
                            <!-- submitFormApplicant() check if a file is selected and if not does regular submit -->
                        </submit>
    </fieldset>
</form>

1 Answer 1

1

I think that unbinding the event is required because of the closed over variables that are captured with the .on('click', ... anonymous function. I am pretty sure your code can be structured to not rely on the closure, thus removing the need to unbind from ng-click. However, without seeing your code, I cannot be sure that closures are your problem nor can I really recommend how restructure your code if they are.

Sign up to request clarification or add additional context in comments.

4 Comments

A standard form, with a button that bind to the submit() function with ng-click. Edired: added a summarized example of my code.
@OlegTikhonov Where is the code where you are actually using the plugin?
Well, that's all of it, the submit() event is predefined by the blueimp library js files
@OlegTikhonov If you know the event name that you need to unbind, I suppose angular.element().unbind() would work. Sorry I can't be anymore help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.