• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

90
Views
No se pueden reemplazar más de 2 valores de matriz

Quiero reemplazar mi matriz existente con una nueva matriz. Pero no puedo agregar/reemplazar más de 2 valores de matriz. Después de 2 valores, se atasca aunque las variables muestren múltiples valores en la consola.

 function add_comments_in_editor() { var comment = ''; // Get selected Action $('input[type=radio]:checked').each(function() { comment = '<strong>' + actions[$(this).attr('id')] + '</strong>'; window.radioNew = '<strong>' + actions[$(this).attr('id')] + '</strong>'; }); // Get selected reason var arrCheck = []; window.newCheck = []; var arrOld = []; $('.voting_parameters input[type=checkbox]:checked').each(function() { var voting_parameter_id = $(this).attr('id'); voting_parameters_array[$(this).attr('id')] + '</li>'; arrCheck.push('<li>' + voting_parameters_array[$(this).attr('id')]); window.newCheck = arrCheck; // Get selected reasons parameters $(this).parent().next('.voting_parameter_reasons').find('input:checkbox').each(function() { if ($(this).is(':checked')) { var voting_parameter_reasons_id = $(this).attr('id'); var reason_index = (voting_parameter_reasons_array[voting_parameter_id].map(function(item) { return item.voting_parameter_reason_id; }).indexOf(voting_parameter_reasons_id)) voting_parameter_reasons_array[voting_parameter_id][reason_index]['reason_name'] + '</li></ul>'; } }); var radioOld = window.oldRadio || ''; var checkOld = window.oldCheck || ''; tinyMCE.activeEditor.setContent(tinyMCE.activeEditor.getContent().replace(checkOld, window.newCheck).replace(radioOld, window.radioNew)); window.oldRadio = '<p><strong>' + actions[$('input[type=radio]:checked').attr('id')] + '</strong></p>'; arrOld.push('<li>' + voting_parameters_array[$('.voting_parameters input[type=checkbox]:checked').attr('id')]); window.oldCheck = arrCheck; }

Solo necesito ver por qué no puedo reemplazar más de 2 valores.

almost 3 years ago · Santiago Gelvez
1 answers
Answer question

0

String.prototype.replaceAll()

Ref: https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll

tinyMCE.activeEditor.getContent().replaceAll(checkOld, window.newCheck)

almost 3 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error