Commit 2229fe99 authored by Chenu Denis's avatar Chenu Denis
Browse files

[fix] Allow usage of event for unload

parent cffe4b54
......@@ -8,7 +8,7 @@
<author>Denis Chenu</author>
<authorUrl>https://extensions.sondages.pro/reloadanyresponse</authorUrl>
<supportUrl>https://support.sondages.pro/</supportUrl>
<version>5.5.0</version>
<version>5.5.1</version>
<license>GNU Affero General Public License v3.0</license>
<description><![CDATA[Allow to reload any response for admin user and respondant.]]></description>
</metadata>
......
......@@ -6,7 +6,7 @@
* @author Denis Chenu <denis@sondages.pro>
* @copyright 2018-2022 Denis Chenu <http://www.sondages.pro>
* @license AGPL v3
* @version 5.5.0
* @version 5.5.1
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -998,9 +998,9 @@ class reloadAnyResponse extends PluginBase
'plugins/direct',
array('plugin' => get_class($this), 'function' => 'close','sid' => $this->surveyId,'srid' => $srid)
);
$onBeforeUnload = "window.onbeforeunload = function(e) {\n";
$onBeforeUnload = "$(window).on('unload', function() { \n";
$onBeforeUnload .= " jQuery.ajax({ async: false, url:'{$ajaxUrl}' });\n";
$onBeforeUnload .= "}\n";
$onBeforeUnload .= "})\n";
Yii::app()->getClientScript()->registerScript("reloadAnyResponseBeforeUnload", $onBeforeUnload, CClientScript::POS_HEAD);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment