Skip to main content
Nintex Community Menu Bar
Question

Monitor on('input') for a given RichText Element

  • July 12, 2024
  • 1 reply
  • 1 view

Forum|alt.badge.img+2

I have page which has several RichText elements associated with a field. For each row of the model, that field will be translated to a RichText element. I need to monitor the keyup or input changes for that given field so, given a scenario, I can perform some conditional translation (not similar to mustache).

Something similar to this:

$(document).ready(function() {
    // Replace "formId" with the ID of your form
    $('#formId textarea').keyup(function() {
        // Get the value of the textarea that triggered the keyup event
        var text = $(this).val();
        console.log(text); // You can replace this with any action you want to perform with the text
    });
});

Anyone know if this is possible?

Translate
Did this topic help you find an answer to your question?

1 reply

Forum|alt.badge.img+10
  • Scholar
  • 223 replies
  • July 12, 2024

Are you using V1 or V2? This should be possible in V1 using the ID of the input box. This may be possible in V2 as well. I’d recommend inspecting the field on the page to see whether or not it has an ID you can use.

It may or may not work on $(document).ready … might depend on whether or not the field is rendered yet. You could keep checking and not apply the event until the field is rendered.

Possible example code:

// Function to add event listener when textarea is available
function addEventListenerWhenAvailable() {
  const textarea = document.getElementById('myTextarea');
  if (textarea) {
    // If textarea is available, add the event listener
    textarea.addEventListener('input', function() {
      console.log('Textarea content changed:', textarea.value);
    });
    clearInterval(checkTextareaInterval); // Clear the interval
  }
}

// Check for textarea every 100 milliseconds
const checkTextareaInterval = setInterval(addEventListenerWhenAvailable, 100);
Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings