-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Client event API
Most of elFinder events pass some data to event handlers. This data stored in event.data, can be object, string or undefined.
$('selector').elfinder({
// options ...
handlers : {
select : function(event, elfinderInstance) {
console.log(event.data);
console.log(event.data.selected); // selected files hashes list
}
}
});var elfinder = $(selector).elfinder(options).elfinder('instance');
// or
var elfinder = new window.elFinder(document.getElementById('my-id'), options);
elfinder.bind('upload', function(event) { ... });
elfinder.unbind('load', function(event) { ... });
elfinder.one('load', function(event) { ... }); // execute once and unbind event after, similar to jQuery.one()-
initcalled once after elFinder node created -
loadcalled once elFinder got first connector response -
apicalled once elFinder got first connector response andevent.datacontains api version -
enableelFinder get focus -
disableelFinder lost focus -
openon folder open -
selectcalled on file(s) select/unselect -
dblclickcalled on file double click -
addcalled when file(s) added (fired by several commands) -
removecalled when file(s) removed (fired by several commands) -
changecalled when file was changed (fired by several commands) -
uploadcalled on file(s) upload -
synccalled on elFinder content syncing (command "reload") -
changeclipboardcalled on copy/cut -
pastecalled on paste of copied files renameduplicatedownload-
getcalled when got response with file content to edit resizearchiveextractcontextmenu-
hovercalled on mouseleave/mouseenter file area in cwd -
viewchangeon icons/list view change sortchange-
searchstartafter user pressed enter in search field -
searchwhen got search results -
searchendwhen search field cleaned -
destroyafter elFinder instance destroyed -
hideafter elFinder hided -
showafter elFinder showed
The event [event]done will fire at after calling all of the [event] callbacks.
No data is passed to this callbacks.
The event [event]fail will fire if it fails to execute this event command.
The response of the back-end has been saved in the event.data.
Command execution can be canceled. (Live Demo)
The callback event.data object
{
opts: {...}, // Options object that passed to request()
result: true // Value to control command execution
}is passed. event.data object is changeable in callback.
To cancel command execution, set event.data.result to false, or set jQuery.Deferred object to event.data.result and asynchronously call jQuery.Deferred().reject(). When setting the jQuery.Deferred object, calling jQuery.Deferred().resolve() will execute the suspended command.