Search code examples
javascriptjqueryfroala

get ID of current froala editor


I added a custom button to my Froala editor.

  $.FroalaEditor.DefineIcon('yt', {NAME: 'plus'});
  $.FroalaEditor.RegisterCommand('yt', {
    title: 'make yt',
    focus: true,
    undo: true,
    refreshAfterCallback: true,
    callback: function () {
       console.log(this);
    }
  });

when I click the button, console.log(this) shows

b {id: 1, opts: {…}, sid: 1, shared: {…}, $oel: m.fn.init(1), …}
$box:m.fn.init [div#jobEditor.fr-box.fr-basic.fr-top, context: div#jobEditor.fr-box.fr-basic.fr-top]
$doc:m.fn.init [document, context: document]
$el:m.fn.init [div.fr-element.fr-view]
$oel:m.fn.init [div#jobEditor.fr-box.fr-basic.fr-top, context: di...
(more stuff)

I see the ID of the DIV that I want (#jobEditor). How do I extract that from "this"?


Solution

  • this.$box.prop('id')

    or

    this.$box[0].id