mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 00:58:55 +01:00
fix etemplate2.postSubmit() to not destroy any eT2 session, by unbinding window.onbeforeunload and rebinding it again after 100ms
Before postSubmit was unbinding only if current etemplates destroy_session was bound and causes so an other etemplates session_destroy to fire. postSubmit now allways rebinds the session_destroy handler of current etemplate assuming it is only used for downloads, where current etemplate (and session) should persist.
This commit is contained in:
parent
4b58e87080
commit
a4d39d5873
@ -305,6 +305,13 @@ etemplate2.prototype.unbind_unload = function()
|
|||||||
{
|
{
|
||||||
window.onbeforeunload = null;
|
window.onbeforeunload = null;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var onbeforeunload = window.onbeforeunload;
|
||||||
|
window.onbeforeunload = null;
|
||||||
|
// bind unload handler again (can NOT do it direct, as this would be quick enough to be still triggered!)
|
||||||
|
window.setTimeout(function(){window.onbeforeunload = onbeforeunload;}, 100);
|
||||||
|
}
|
||||||
delete this.destroy_session;
|
delete this.destroy_session;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -756,8 +763,10 @@ etemplate2.prototype.submit = function(button, async, no_validation, _container)
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does a full form post submit.
|
* Does a full form post submit necessary for downloads
|
||||||
* Only use this one if you need it, use the ajax submit() instead
|
*
|
||||||
|
* Only use this one if you need it, use the ajax submit() instead.
|
||||||
|
* It ensures eT2 session continues to exist on server by unbinding unload handler and rebinding it.
|
||||||
*/
|
*/
|
||||||
etemplate2.prototype.postSubmit = function()
|
etemplate2.prototype.postSubmit = function()
|
||||||
{
|
{
|
||||||
@ -793,6 +802,9 @@ etemplate2.prototype.postSubmit = function()
|
|||||||
input.value = egw().jsonEncode(values);
|
input.value = egw().jsonEncode(values);
|
||||||
form.append(input);
|
form.append(input);
|
||||||
form.appendTo(jQuery('body')).submit();
|
form.appendTo(jQuery('body')).submit();
|
||||||
|
|
||||||
|
// 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