Elfinder: Question / Feature request: Global event handler for failed requests

Created on 17 Sep 2018  路  4Comments  路  Source: Studio-42/elFinder

What do I exactly need is a handler which would be executed (if set of course) when an ajax request failed. Basically I'd like to be able to modify the behavior of "request()->error()" javascript function.

What more - in the handler, I'd like to have an option to cancel further processing of original error() .

Why? Because right now, when the session of my app expires, and let's say I try to create a new folder - I get an ugly response ("Data is not JSON...." with the source of login page).

Having proposed handler I could easily redirect to login page.

I think such a functionality could also be useful for done() and success().

PS. Of course globally for every command.
PS2. The handler should accept as a parameter the command name from which it was invoked and the final URL after an Ajax redirect (if there was one).

client feature howto

All 4 comments

@mozan I added an event requestError to fix this issue. see 81ba8a456d52dac152efaa134e8726a875209244. Thanks! 馃憤

@nao-pon It's a pleasure working with You. Nice and clean, works perfectly :)

Just one more question. I'm not quite sure (to be honest - I have no idea) how to display a modal dialog, with just a simple info, that the session timed out.

This is what I did. It works - almost... The dialog is not modal:(

if (loc) {
    fm.error(["Your session expired. You'll be redirected to the login page.", ''], {modal: true});

    // prevent showing error messages
    e.preventDefault();
    window.location = loc;
}

@mozan Please use an option close.

if (loc) {
    // prevent showing error messages
    e.preventDefault();
    fm.error('Your session expired. You\'ll be redirected to the login page.', {
        modal: true,
        close: function() {
            window.location = loc;
        }
    });
}

@nao-pon Exactly what I needed. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

isreehari picture isreehari  路  12Comments

toastbrotch picture toastbrotch  路  13Comments

Offerel picture Offerel  路  10Comments

ghost picture ghost  路  11Comments

bitbybit picture bitbybit  路  13Comments