Question

I'm using elFinder to access some stored files on a website, but the files themselves aren't directly accessible. Instead, I request them through a particular controller action. So I override the getFileCallback in elFinder to use a custom URL:

getFileCallback: function (file) {
    window.location.href = '@Url.Action("File", "Home")' + '?path=' + encodeURI(file);
}

This works great for double-clicking on a file. However, if I just select the file and use the Open button in the elFinder toolbar, this callback isn't used. Instead it opens a popup and tries to use the default URL, which results in a 404 error.

Is there a way to override the behavior of the Open button in the toolbar? I've been trying various things in the Client event API or in the commands options, but can't seem to find anything that modifies the Open behavior.

Is there any way to do this?

Was it helpful?

Solution

What I ended up doing was overriding the open function entirely:

elFinder.prototype.commands.open = function () {
    // custom code
};

(Just do this in a script block after loading the elFinder code.)

I can't say if it's ideal, and it will take some tweaking if there are major upgrades to elFinder, but it's definitely doing the job. (Going from this, I also started overriding some of the other functions which use the URL, such as the anchor tag in the info pop-up.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top