Client event API - Studio-42/elFinder GitHub Wiki
Most of elFinder events pass some data to event handlers. This data stored in event.data
, can be object, string or undefined.
Events handlers can be attached in two ways:
On elFinder init
$('selector').elfinder({
// options ...
handlers : {
select : function(event, elfinderInstance) {
console.log(event.data);
console.log(event.data.selected); // selected files hashes list
}
}
});
After elFinder init:
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()
Event list
init
called once after elFinder node createdload
called once elFinder got first connector responseapi
called once elFinder got first connector response andevent.data
contains api versionenable
elFinder get focusdisable
elFinder lost focusopen
on folder openselect
called on file(s) select/unselectdblclick
called on file double clickadd
called when file(s) added (fired by several commands)remove
called when file(s) removed (fired by several commands)change
called when file was changed (fired by several commands)upload
called on file(s) uploadsync
called on elFinder content syncing (command "reload")changeclipboard
called on copy/cutpaste
called on paste of copied filesrename
duplicate
download
get
called when got response with file content to editresize
archive
extract
contextmenu
hover
called on mouseleave/mouseenter file area in cwdviewchange
on icons/list view changesortchange
searchstart
after user pressed enter in search fieldsearch
when got search resultssearchend
when search field cleaneddestroy
after elFinder instance destroyedhide
after elFinder hidedshow
after elFinder showed
EventName + "done" event (>= elFinder 2.1.15)
The event [event]done
will fire at after calling all of the [event] callbacks.
No data is passed to this callbacks.
EventName + "fail" event (>= elFinder 2.1.16)
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
.
"request." + Command Name (>= elFinder 2.1.20)
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.