How can I move TinyMCE's toolbar into a modal popup?

Posted by Nate Wagar on Stack Overflow See other posts from Stack Overflow or by Nate Wagar
Published on 2009-10-19T18:09:55Z Indexed on 2010/05/07 4:08 UTC
Read the original article Hit count: 223

Filed under:
|

I'm using TinyMCE & jQuery and am having a problem moving TinyMCE's external toolbar to another location in the DOM.

To further complicate things, there are multiple TinyMCE instances on the page. I only want the toolbar for the one that's currently being edited.

Here's some sample code:

$(textarea).tinymce({
  setup: function(ed) {setupMCEToolbar(ed, componentID, displaySettingsPane)}
  ,script_url: '/clubs/data/shared/scripts/tiny_mce/tiny_mce.js'
  ,theme : "advanced"
  ,plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template"
   ,theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect"
  ,theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor"
  ,theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen"
  ,theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak"
  ,theme_advanced_toolbar_location : "external"
  ,theme_advanced_toolbar_align : "left"
  ,theme_advanced_statusbar_location : "bottom"
  ,theme_advanced_resizing : true
 });

var setupMCEToolbar = function (mce, componentID, displaySettingsPane)
{
 mce.onClick.add(function(ed,e){
  displaySettingsPane($('#' + componentID));
  $('#' + componentID).fetch('.mceExternalToolbar').eq(0).appendTo('#settingsPaneContent');
 });
}

Basically, it seems as though the setupMCEToolbar function cannot track down the mceExternalToolbar to move it.

Has anyone ever had success trying to do something like this?

EDIT It's a Monday alright... it couldn't find the external toolbar because I was using children() instead of fetch().

There's still an issue in that: 1) Moving it is incredibly slow and 2) Once it moves, TinyMCE breaks.

EDIT 2 A bit more clarification: The modal is draggable, thus making any purely-CSS workarounds a bit awkward...

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about tinymce