Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6544171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:26:02+00:00 2026-05-25T11:26:02+00:00

Added tinyMCE as inline editor. Have a next probllem : first time this is

  • 0

Added tinyMCE as inline editor. Have a next probllem : first time this is work good – show with custom style (as I setup), works correctly but when I click cancel and then start edit again I have empty editor – without text in edit area. so this is a code:
UPD : cm.Node – wrapper for docuement.createElement and el.setAttribute, cm.getByAttr(‘attr’, ‘attr_val’, el) – get elemnt by attr from el. req – wrapper for AJAX, cm.merge – like array_merge in PHP

var EditBlock = function(){
    var my = this;
    var o = cm.merge({
        'id' : '',
        'act' : '',
        'val' : '',
        'nobr' : false,
        'text' : false,
        'onSaved' : function(){},
        'onSave' : function(){},
        'params' : {'iconsPath' : 'interface/common/images/stdc/nicEditorIcons.gif'}
    }, arguments[0]);
    var prefix = 'tinyMCE_' + Math.random() + '_';
    var node = cm.getEl(o.id);
    var txtArea = cm.addClass(cm.Node('textarea', {'id' : prefix + o.id, 'style': ('width:' + node.offsetWidth + 'px')}), prefix + o.id);
    var saveBtn = cm.Node('input', {'type':'button', 'value':'Save'});
    var cancelBtn = cm.Node('input', {'type':'button', 'value':'Cancel'});
    var container = cm.Node('div', txtArea, cm.Node('div', saveBtn, cancelBtn));

    var plainText = function(node){
        var str = '';
        var childs = node.childNodes;        
        for(var i = 0, ln = childs.length; i < ln; i++){
            if(childs[i].nodeType == 3)
                str += childs[i].nodeValue;
            else if(childs[i].childNodes.length)
                str += plainText(childs[i]);
        }
        return str;
    }

    var init = function(){
        node.onclick = my.edit;
        cancelBtn.onclick = my.close;
        saveBtn.onclick = function(){
            my.save();
            my.close();
        }
    }

    my.save = function(){
        var tmp = cm.Node('div', tinyMCE.get(prefix + o.id).getContent());
        var content = o.text? plainText(tmp) : tmp.innerHTML;
        o.onSave(content);
        node.innerHTML = content;
        req({
        'act' : o.act, 
        'data' : 'data[content]=' + escape(content) + (o.val? '&data[val]=' + o.val : ''), 'handler' : function(){o.onSaved(content)}
        });
    }
    my.close = function(){
        tinyMCE.init({
            'editor_deselector' : prefix + o.id
        });
        container.parentNode.removeChild(container);
        node.style.display = 'block';
    }
    my.edit = function(){
        txtArea.value = node.innerHTML;
        node.style.display = 'none';
        node.parentNode.insertBefore(container, node);
        var styles = '';
        var styleRef = cm.getByAttr('rel', 'stylesheet');
        for(var i = 0, ln = styleRef.length; i < ln; i++){
            styles += (i > 0? ',' : '') + styleRef[i].href;
        }
        tinyMCE.init({
            'height' : '100%',
            'content_css' : styles + ',/sdtc-new/nc/interface/common/css/mce-editor.css',
            'mode' : "specific_textareas",
            'editor_selector' : prefix + o.id
        });

    }
    init();
}

use this like :

new EditBlock({'onSave' : function(content){
            page.content = content;
            viewDepartment(page);
        }, 'id':'depContent', 'act' : '/departments/setContent/', 'val' : page.id, 'params' : {buttonList : ['fontSize','bold','italic','underline','strikeThrough','html']}});

So … again about problem. When first time start to edit that all works fine when click save – all works too (still exists some bugs but after saving I can click and start edit again) but when click cancel that editor is hide but when I click to edit again I have a empty edit area. I see to console and find that after canceling when I start editing again then I create new edit but old not destroy – only hidden.

I try to usetynyMCE.Editor class methods like hide and show and setContent and was a some result – after canceling I could edit egain but edit area was without styles and buttons.

Please help. If would be quaestion by code – I pleasure to answer.
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:26:03+00:00Added an answer on May 25, 2026 at 11:26 am

    Don’t use hide() and show() here. You should shut down tinymce correctly in order to be able to reinitialize a tinymce editor with the same id as the first one.

    To shut down an edtor instance use:

    tinymce.execCommand('mceRemoveControl',true,'editor_id');
    

    To reinitialize use

    tinymce.execCommand('mceAddControl',true,'editor_id');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a blog section on my site that has the TinyMce editor. I
I've added a custom button to TinyMCE which brings up a bespoke link-picker. When
I am using the TinyMCE editor. I have a div element. When an edit
I have a TinyMCE editor that I need to add a tag to in
I'm using TinyMCE with ImageManager. I have everything set up right, but i added
Added: Working with SQL Server 2000 and 2005, so has to work on both.
ADDED: This question is now, I believe, subsumed by this one: Using GNU Screen
I added a custom install action to my installer to add one of my
I added some custom fields (public booleans) to the global class in global.asax.cs which
I'm using TinyMCE on the text-areas in my Magento admin section. I have my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.