forked from extern/egroupware
Etemplate: Different way to download generated files to avoid destroying sessions of not-visible etemplates
This commit is contained in:
parent
b5ef5126c6
commit
293f9cc446
@ -324,14 +324,17 @@ var etemplate2 = /** @class */ (function () {
|
||||
/**
|
||||
* Download a URL not triggering our unload handler and therefore destroying our et2 request
|
||||
*
|
||||
* We use a new anchor element to avoid not destroying other etemplates as well, which
|
||||
* is what happens if we use window.location
|
||||
*
|
||||
* @param {string} _url
|
||||
*/
|
||||
etemplate2.prototype.download = function (_url) {
|
||||
// need to unbind unload handler to NOT destroy et2 session
|
||||
this.unbind_unload();
|
||||
document.location = _url;
|
||||
// bind unload handler again (can NOT do it direct, as this would be quick enough to be still triggered!)
|
||||
window.setTimeout(jQuery.proxy(this.bind_unload, this), 100);
|
||||
var a = document.createElement('a');
|
||||
a.href = _url;
|
||||
a.download = 'download';
|
||||
// Programmatically trigger a click on the anchor element
|
||||
a.click();
|
||||
};
|
||||
/**
|
||||
* Loads the template from the given URL and sets the data object
|
||||
|
@ -414,17 +414,19 @@ export class etemplate2
|
||||
/**
|
||||
* Download a URL not triggering our unload handler and therefore destroying our et2 request
|
||||
*
|
||||
* We use a new anchor element to avoid not destroying other etemplates as well, which
|
||||
* is what happens if we use window.location
|
||||
*
|
||||
* @param {string} _url
|
||||
*/
|
||||
download(_url)
|
||||
{
|
||||
// need to unbind unload handler to NOT destroy et2 session
|
||||
this.unbind_unload();
|
||||
const a = document.createElement('a');
|
||||
a.href = _url;
|
||||
a.download = 'download';
|
||||
|
||||
document.location = _url;
|
||||
|
||||
// bind unload handler again (can NOT do it direct, as this would be quick enough to be still triggered!)
|
||||
window.setTimeout(jQuery.proxy(this.bind_unload, this), 100);
|
||||
// Programmatically trigger a click on the anchor element
|
||||
a.click();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user