javascriptjquerytinymceedit-in-place

Multiple TinyMCE editors, but only one toolbar?


I've looked around the forum, but cannot seem to find a definite answer to this problem...

I'm using jQuery and TinyMCE on our website. I've gone through the docs of TinyMCE, but am still getting lost I'm afraid. We're doing an interface that requires edit-in-place in multiple places in the page. The only thing is, each of these will have all the editing choices from TinyMCE in one toolbar at the top. So, to recap it, it's multiple editors (that each have no toolbars of their own, just a place to edit or select the text) and only one toolbar at the top of the page to control whichever textbox is active at the time.

How could this be achieved? Is it even possible? Any help, any push in the right direction, any hints/tips/knowledge at all on this problem would be a great, great help.

Thanks, James


Solution

  • I know there is a way to show the toolbar when a textarea is focused into, and then hide on textarea blur event - so that could be one route.

    I do a similar sort of thing (with multiple textareas) where i load in demand the tinyMCE, so something like loading on demand and then destroy when finished with (blur event) might be what you're after.

    I can't give you all of my code as it's actually part of my employer's I.P, but here is a rough outline to it, hopefully should help. The tinyMCE_GZ is part of the gzip which is off the tinyMCE site.

    isTinyMCE_Loaded = false;
    
    jQuery('.my-textarea').one("click", function(){
        BuildWYSIWYG.Full(jQuery(this));
    })
    
    BuildWYSIWYG.OnDemand: function(callback){
        tinyMCE_GZ.init({
            plugins : 'style,table,advhr,advimage,advlink,insertdatetime,preview,searchreplace,contextmenu,paste,fullscreen,visualchars,nonbreaking,xhtmlxtras,safari,tinybrowser',
            themes : 'simple,advanced',
            languages : 'en',
            disk_cache : true,
            debug : false
        }, function(){ 
            isTinyMCE_Loaded = true; 
            callback();
        });
    };
    BuildWYSIWYG.Full: function(el){   
        settings.elements = jQuery(el).attr("id");
    
        // Build advanced wysiwyg
        if (isTinyMCE_Loaded){
            tinyMCE.init(settings);
        } else {
            BuildWYSIWYG.OnDemand(function(){
                tinyMCE.init(settings);
            });
        }
    }