Skip to content

Commit

Permalink
Fixed uploading only files without submitting whole form
Browse files Browse the repository at this point in the history
  • Loading branch information
CTOlet committed Jun 19, 2015
1 parent e2b49c2 commit 44f71b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Usage
Change log
----------

- **June 19, 2015** - Fixed uploading only files without submitting whole form
- **May 1, 2015** - Fixed uploading when connection is slow or uploading time is long. Now ```onclick``` event on submit button is deprecated
- **Apr 16, 2015** - Allow users to have a custom behavior class inheriting from FileBehavior.
- **Apr 4, 2015** - Now all temp uploaded files will be deleted on every new form opened.
Expand Down
15 changes: 13 additions & 2 deletions components/AttachmentsInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function init()
var form = fileInput.closest('form');
var filesUploaded = false;
var filesToUpload = 0;
var uploadButtonClicked = false;
//var formSubmit = false;
form.on('beforeSubmit', function(event) { // form submit event
console.log('submit');
Expand All @@ -62,13 +63,23 @@ public function init()
}
});
fileInput.on('filebatchpreupload', function(event, data, previewId, index) {
var form = data.form, files = data.files, extra = data.extra,
response = data.response, reader = data.reader;
uploadButtonClicked = true;
});
fileInput.on('filebatchuploadcomplete', function(event, files, extra) { // all files successfully uploaded
//var form = data.form;
//console.log(form);
console.log('uploaded');
//console.log('uploaded');
filesUploaded = true;
$('#file-input').fileinput('unlock');
form.submit();
if (!uploadButtonClicked) {
form.submit();
} else {
uploadButtonClicked = false;
}
});
fileInput.on('filebatchselected', function(event, files) { // there are some files to upload
Expand Down

0 comments on commit 44f71b5

Please sign in to comment.