Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[js:core] lost binded user functions with node.elfinder('reload') #2079

Closed
nao-pon opened this issue Jun 29, 2017 · 0 comments
Closed

[js:core] lost binded user functions with node.elfinder('reload') #2079

nao-pon opened this issue Jun 29, 2017 · 0 comments
Assignees

Comments

@nao-pon
Copy link
Member

nao-pon commented Jun 29, 2017

Since node.elfinder ('reload') destroys the elFinder instance once, the registered user function is lost.

As a countermeasure, elFinder provides a new registration method for user functions.

Make the callback function registered for preparation for bootup, and register the callback function with the second argument of new elFinder() or with the option value bootCallback.

  • The this object in the function is an elFinder node
  • The first parameter is elFinder Instance
  • The second parameter is an object of other parameters
    For now it can use dfrdsBeforeBootup Array

The dfrdsBeforeBootup array has a value ofjQuery.Deferred()object. The bootup sequence is suspended until all jQuery.Deferred() is in the resolved state.

$('#elfinder').elfinder(
    // 1st Arg - options
    {
        // Connector URL
        url : 'php/connector.minimal.php'
    },
    
    // 2nd Arg - before boot up function
    function(fm, extraObj) {
        /* any bind functions etc. */
        fm.bind('init', function() {
            // any your code
        });
        // for example set document.title dynamically.
        var title = document.title;
        fm.bind('open', function() {
            var path = '',
                cwd  = fm.cwd();
            if (cwd) {
                path = fm.path(cwd.hash) || null;
            }
            document.title = path? path + ':' + title : title;
        }).bind('destroy', function() {
            document.title = title;
        });
    }
);

OR

$('#elfinder').elfinder({
    url : 'php/connector.minimal.php' // connector URL (REQUIRED)
    // bootCalback calls at before elFinder boot up 
    ,bootCallback : function(fm, extraObj) {
        /* any bind functions etc. */
        fm.bind('init', function() {
            // any your code
        });
        // for example set document.title dynamically.
        var title = document.title;
        fm.bind('open', function() {
            var path = '',
                cwd  = fm.cwd();
            if (cwd) {
                path = fm.path(cwd.hash) || null;
            }
            document.title = path? path + ':' + title : title;
        }).bind('destroy', function() {
            document.title = title;
        });
    }
});
@nao-pon nao-pon self-assigned this Jun 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant