Skip to content

Integration with elRTE 1.x

DavidJapan edited this page Mar 27, 2013 · 17 revisions

Option 1 - Create/destroy elFinder on every icon click:

$('selector').elrte({
  fmOpen : function(callback) {
    $('<div />').dialogelfinder({
      url: 'php/connector.php',
      commandsOptions: {
        getfile: {
          oncomplete: 'destroy' // destroy elFinder after file selection
        }
      },
      getFileCallback: callback // pass callback to file manager
    });
  }
});

Demo 1 (source)

Option 2 - Create dialog only once and reuse it if needed again

var dialog;
$('selector').elrte({
  fmOpen: function(callback) {
    if (!dialog) {
      // create new elFinder
      dialog = $('<div />').dialogelfinder({
        url: 'connectors/php/connector.php',
        commandsOptions: {
          getfile: {
            oncomplete : 'close' // close/hide elFinder
          }
        },
        getFileCallback: callback // pass callback to file manager
      });
    } else {
      // reopen elFinder
      dialog.dialogelfinder('open')
    }
  }
});

Discussion

http://elrte.org/redmine/boards/2/topics/3210?r=3232#message-3232

UPDATE (delagen): if don't work try this update:

instead of

getFileCallback: callback

write this:

getFileCallback: function(file) { callback(file.path); }

UPDATE I have found the above two suggestions cause errors and this line works:

getFileCallback: function(file) { callback(file.url); }
Clone this wiki locally