knockout.files
knockout.files copied to clipboard
Binding handler doesn't execute if I try to upload same file twice
It appears the binding handler doesn't execute if I try to upload the same file twice, but only back to back. If I upload file A, file B, then upload A again, it executes fine. But I try to upload file A then try A again, the binding handler doesn't seem to fire.
It looks like the problem is with the fact that the input retains the same value and thus, I suppose, the binding handler doesn't realize that the input has changed, so it won't fire.
In the binding hander, it looks like you need to pass the element to the loadedCallBack:
reader.onload = function (fileLoadedEvent) {
loadedCallback(file, fileLoadedEvent.target.result, element);
};
And, then in your callback:
yourCallBack = function (fileMetaData, uploadData, target) {
//do stuff with the data
$(target).val(''); //In case you need to upload same file twice
};
Hey, if you solve it then just push up a merge request and I will get it merged in.
PhillyWebGuy: Yep, this seems to be the case. Since you havn't pushed it, I didn't want to change knockout.files.js, so I just added this to my callback funciton: $('#image_files').val('');