1

Morning.

I am currently trying to add a quick edit feature to my application. I have simply data passed using fancybox wich loads the appropriate data into tinymce.

The problem being once i have closed the fancybox down for the first time and move onto the second item to edit and click, everything loads up ok visualy (including tinyMCE) but i cannot edit within the wysiwyg editor with firebug displaying undefined 'e' or 't' or 'd' whichever one it decides to show...

any help would be muchly appreciated.

EDIT

try{
    function remove_mce(){
        tinyMCE.execCommand('mceRemoveControl',false,'elm1');   
    }
    $('#tree a').bind('click', function(){
        $('#tree ul li ul').removeClass('showBranch');
        var ob = $(this);
        var ob_parent = ob.parent('li');
        ob_parent.removeClass('branch').addClass('branch-open');
        ob.parents('ul').addClass('showBranch');
        $('~ li', ob_parent).children(':first').addClass('showBranch');
        return false;
    });
    $("#tree .product a").fancybox({
        'autoDimensions':   false,
        'width'         :   '750',
        'height'        :   '90%',
        'transitionIn'  :   'elastic',
        'transitionOut' :   'elastic',
        'speedIn'       :   600, 
        'speedOut'      :   200, 
        'overlayShow'   :   true,
        'hideOnOverlayClick' : false,
        'onCleanup'     :   remove_mce()
    });
}catch(err){alert(err.message);}
thecoop
  • 45,220
  • 19
  • 132
  • 189
Phil Jackson
  • 10,238
  • 23
  • 96
  • 130

1 Answers1

2

TinyMCE will have problems if its controls are removed by something else then reopened, as it seems that fancybox is doing.

If possible you should create the TinyMCE control when the fancybox is opened using this command:

tinyMCE.execCommand('mceAddControl', false, "control id here");

Then when the fancybox is closed also close the TinyMCE control:

tinyMCE.execCommand('mceRemoveControl', false, "control id here");  
gutch
  • 6,959
  • 3
  • 36
  • 53
  • thanks for the reply! sounds like a solution but could you tell me what the control id is please? – Phil Jackson Dec 16 '10 at 06:33
  • The control ID is up to you - it would be the HTML ID of the textarea that you're using TinyMCE with. – gutch Dec 16 '10 at 06:48
  • and also I cannot see from the documentation what 'false' is in relation to in your answer. Do you know? – Phil Jackson Dec 16 '10 at 08:07
  • false is not relevant here, but the control_id is. the control id is the tinymce editor id, if your textarea does not have an id it defaults to 'content'. when tinymce is open you can get the id using firebug an typing "tinymce.editors", this will give you an array of all tinymce editor instances the param id reffers to this control id – Thariama Dec 16 '10 at 08:49
  • The question is still not answered due to the error `tinyMCE is not defined`. does this have anything to do with the fact i am using the jquery version?? – Phil Jackson Dec 16 '10 at 11:53
  • It looks like your code is calling the `remove_mce` function during page load, but you want it to run only when the 'onCleanup' event is called. Because the page is loading when the method is run, TinyMCE probably isn't ready and thus you get `tinyMCE is not defined`. Try removing the brackets from your reference to `remove_mce`, ie just have `'onCleanup' : remove_mce` – gutch Dec 17 '10 at 05:25