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

  • SEARCH
  • Home
  • 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 9140713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:33:08+00:00 2026-06-17T09:33:08+00:00

I believe the problem with finding/replacing text is when a wysiwyg steps into the

  • 0

I believe the problem with finding/replacing text is when a wysiwyg steps into the mix.
However, I’m sure someone has figured out how to do the magic.

Here’s the textarea, with no editor attached:

<textarea id="template1" style="width:400px; height:200px;">
<div>Dear {{companyname}},</div>
<div>A new Support Case has been opened for you.</div>
<div>Support Case description:</div>
.........more html text follows
</textarea>

<script language="javascript" type="text/javascript">
$(document).ready(function(){

   var str = $("#template1").val();
   var newstr = str.replace("{{companyname}}", "ACME Inc");
   $("#template1").val(newstr);

}); 
</script>

Without the editor, I’m good to go.
As soon as I apply my editor of choice (TinyMCE), the replace() method gets ignored.

Does anyone know why?

  • 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-06-17T09:33:09+00:00Added an answer on June 17, 2026 at 9:33 am

    There are two reasons why your replace function doesn’t work.

    1. The contents of the former textarea get replaced, but you cannot see the result because tinymce hides the textarea and uses a contenteditable iframe to load and style the former contents. The editor content gets written back to the textarea onSave and onSubmit

    2. $(document).ready all ressources of your page have been loaded, but the tinymce editor is not ready.

    This will lead to the question on how to replace the code in the tinymce editor. $(document).ready won’t help here. You will need use the tinymce configuration paramter onInit

    // Adds an observer to the onInit event using tinyMCE.init
    
    tinyMCE.init({
       ...
       setup : function(ed) {
          ed.onInit.add(function(ed) {
              //console.debug('Editor is done: ' + ed.id);
    
              // replace the editor content
              var str = ed.getContent();
              var newstr = str.replace("{{companyname}}", "ACME Inc");
              ed.setContent(newstr);
          });
       }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe my problem stems from my use of weights and the RelativeLayout that
I believe my problem involves pointers, a concept I often struggle with, but here's
I've searched and I believe my problem is quite unique. I'm aware of the
THIRD EDIT: I now believe that this problem is due to a SOAP version
I believe I am having a security problem related to using the embed tag
I believe I'm having a relatively simple problem with a video player implementation in
I have a problem with some code and I believe it is because of
I can't believe, no one got my problem before. Using joomla 1.5 and VM
I have 5 tables in MySQL, but i believe this is a SQL problem
I've reviewed some posts about lazy loading but I believe my problem is a

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.