Elfinder: How to get the item info with the remove handler

Created on 5 Apr 2018  路  5Comments  路  Source: Studio-42/elFinder

remove: function (event, fm) {
event.data.removed[0].name
}

I need the name of the file that was removed

howto

All 5 comments

@hiagobury Catch the exec event and obtain the file which will be deleted in advance.

var staged = {};
var elf = $('#elfinder').elfinder('instance'); 

elf.bind('exec', function(e, fm) {
    if (e.data.cmd === 'rm') {
        staged = {};
        $.each(e.data.files || fm.selected(), function(i, h) {
            staged[h] = fm.file(h);
        });
    } 
});

elf.bind('remove', function(e, fm) {
    var names;
    if (e.data.removed.length) {
        names = $.map(e.data.removed, function(h) {
            return staged[h]? staged[h].name : null;
        });
        fm.log(names);
    }
});

thank you very much

e.data.files is undefined =(

@hiagobury Sorry, please use e.data.files || fm.selected(). I edited previous comment.

everything perfect, I was letting something happen at the beginning of the file your solution is fine, thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DaeMonSx picture DaeMonSx  路  4Comments

CodeLyokoXtEAM picture CodeLyokoXtEAM  路  3Comments

camgullo picture camgullo  路  3Comments

shiyee picture shiyee  路  3Comments

CodeLyokoXtEAM picture CodeLyokoXtEAM  路  4Comments