Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
Replace a particular text in TinyMCE textarea

I am using TinyMCE editor and I want to replace a particular text. In tinyMCE, I am fetching the previous content and then replacing it with some variable.

$("input:radio").change(function() {
    if ($(this).is(':checked')) {
      if (actions[$(this).attr('id')] != 'Pursue') {
        $('#primary_firm').val('').trigger('change');
        $('#drafting_firm').val('').trigger('change');
      }
      $(this).parents('.actions').siblings('.conclusions').find('input:checkbox').prop('checked', false);
      const oldActionId = window.oldAction;
      console.log(oldActionId);
      tinyMCE.activeEditor.setContent(tinyMCE.activeEditor.getContent().replace(oldActionId, '<b>' + actions[$(this).attr('id')] + '</b>'));
      // Adding comment

      // Hide data of other action
      if (isMobile) {
        $(this).parents('.actions').siblings('.conclusions').css("display", "none");
        $(this).parents('div').next('.conclusions').css("display", "block");
      }
    }
    window.oldAction = actions[$("input[type=radio]:checked").attr('id')];
  });

Now problem is that, the first time oldActionId is undefined. That is, it is not able to fetch the previous selected radio button value so it shows undefined. Any way to fetch the previous selected value.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!