Hi everyone
I have written an AMD module that I would like to run before user logout. So I have tested my AMD module on pessek_chat_plugins_boot function and everythinh seems to work.
elgg_register_event_handler('plugins_boot', 'system', 'pessek_chat_plugins_boot');
function pessek_chat_init() {
∕* My AMD javascript here*/
}
But when I call my AMD module using logout:before event nothing happen could someone help me ?
My code looks as followed
elgg_register_event_handler('plugins_boot', 'system', 'pessek_chat_plugins_boot');
function pessek_chat_init() {
elgg_register_event_handler('logout:before', 'user', 'handle_before_logout');
}
function function handle_before_logout($event, $object_type, $user){
/*My AMDJavascript is called here but nothing happen */
}
Best regard
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Nikolai Shcherbin@rivervanrain

Nikolai Shcherbin - 1 like
- Hermand Pessek@rheman

Hermand Pessek - 0 likes
- Nikolai Shcherbin@rivervanrain

Nikolai Shcherbin - 1 like
- Hermand Pessek@rheman

Hermand Pessek - 0 likes
- Matt Beckett@Beck24

Matt Beckett - 0 likes
You must log in to post replies.Are you sure with it? Maybe:
Check this
Sorry I did a mistake.
I have written an AMD module that I would like to run before user logout. So I have tested my AMD module on pessek_chat_plugins_boot function and everythinh seems to work.
But when I call my AMD module using logout:before event nothing happen could someone help me ?
My code looks as followed
In first,
not
In second, you can not call your JS in this function directly.
Use traditional elgg_load_js or AMD elgg_require_js
Sorry just a mistake about function function durinf copy and paste
I am not using my js directly.
I used elgg_define_js and elgg_require_js in pessek_chat_plugins_boot function and everything work perfectlly but when I do the same thing in handle_before_logout nothing happen
You can't run a javascript function on 'logout:before' because this is a PHP event that happens in an action. Actions do not output a page, which means no javascript is rendered.
Since the page reloads, the only thing I could think you would need to do with javascript on logout is call a remote service for something (like analytics?). If that's the case it would be much better to do that in PHP on the event.
If you absolutely need to do this in javascript you could use some hacky session sniffing to render your js on the next pageload. Of course this means whatever you are doing is being done after the logout has happened, not before.