Skip to main content

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?

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);

Reply