Capture events on tmp download link created by FileUtils

This commit is contained in:
jdescottes
2014-07-13 15:54:13 +02:00
parent 581bd46dcd
commit d4884a2de5
3 changed files with 18 additions and 17 deletions

View File

@@ -1,6 +1,10 @@
(function () {
var ns = $.namespace('pskl.utils');
var stopPropagation = function (e) {
e.stopPropagation();
};
ns.FileUtils = {
readFile : function (file, callback) {
var reader = new FileReader();
@@ -20,7 +24,9 @@
downloadLink.setAttribute('href', content);
downloadLink.setAttribute('download', filename);
document.body.appendChild(downloadLink);
downloadLink.addEventListener('click', stopPropagation);
downloadLink.click();
downloadLink.removeEventListener('click', stopPropagation);
document.body.removeChild(downloadLink);
}
}