$(document).ready(function(){ //textarea fields get tinyMCE loaded when colorbox loading completed $(this).bind('cbox_complete', function(){ $().tinymce({ script_url : 'http://mypaintersplace.com/mod/vazco_lightbox/vendors/tinymce/jscripts/tiny_mce/tiny_mce.js', mode : "none", theme : "advanced", relative_urls : false, theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,bullist,numlist,undo,redo,link,unlink,image,blockquote,code", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]" }); //clearing the remaining tinymce instances $('textarea').livequery(function() { tinyMCE.triggerSave(); }); //adding tinyMCE to all textareas based on separate ids $('textarea').livequery(function() { //alert($(this).attr('id')); tinyMCE.execCommand('mceAddControl', false, $(this).attr('id')); }); }); $('a.toggle_editor').livequery('click', function(event) { var id=event.target.id.slice(7); //alert($(this).hasClass('off')); if ($(this).hasClass('on')){ tinyMCE.execCommand('mceAddControl', false, id); //editorState = 'off'; $(this).removeClass('on'); $(this).addClass('off'); } else{ tinyMCE.execCommand('mceRemoveControl', false, id); $(this).removeClass('off'); $(this).addClass('on'); } return false; }); });