mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
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
|
* 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
|
* @param {string} _url
|
||||||
*/
|
*/
|
||||||
etemplate2.prototype.download = function (_url) {
|
etemplate2.prototype.download = function (_url) {
|
||||||
// need to unbind unload handler to NOT destroy et2 session
|
var a = document.createElement('a');
|
||||||
this.unbind_unload();
|
a.href = _url;
|
||||||
document.location = _url;
|
a.download = 'download';
|
||||||
// bind unload handler again (can NOT do it direct, as this would be quick enough to be still triggered!)
|
// Programmatically trigger a click on the anchor element
|
||||||
window.setTimeout(jQuery.proxy(this.bind_unload, this), 100);
|
a.click();
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Loads the template from the given URL and sets the data object
|
* 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
|
* 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
|
* @param {string} _url
|
||||||
*/
|
*/
|
||||||
download(_url)
|
download(_url)
|
||||||
{
|
{
|
||||||
// need to unbind unload handler to NOT destroy et2 session
|
const a = document.createElement('a');
|
||||||
this.unbind_unload();
|
a.href = _url;
|
||||||
|
a.download = 'download';
|
||||||
|
|
||||||
document.location = _url;
|
// Programmatically trigger a click on the anchor element
|
||||||
|
a.click();
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user