Files
notifications-admin/app/assets/javascripts/fileUpload.js
T

25 lines
519 B
JavaScript
Raw Normal View History

2016-02-02 17:28:30 +00:00
(function(Modules) {
"use strict";
Modules.FileUpload = function() {
2016-02-22 21:37:32 +00:00
let $form;
2016-02-02 17:28:30 +00:00
2016-02-22 21:37:32 +00:00
this.submit = () => $form.trigger('submit');
2016-02-02 17:28:30 +00:00
this.start = function(component) {
2016-02-22 21:37:32 +00:00
$form = $(component);
2016-02-02 17:28:30 +00:00
// Clear the form if the user navigates back to the page
$(window).on("pageshow", () => $form[0].reset());
2016-02-02 17:28:30 +00:00
// Need to put the event on the container, not the input for it to work properly
2016-02-22 21:37:32 +00:00
$form.on('change', '.file-upload-field', this.submit);
2016-02-02 17:28:30 +00:00
};
};
})(window.GOVUK.Modules);