Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Check when a form-field component is loaded in React based module
Hello,
I've created a form-field module based on React.
I want to manipulate the component with Javascript but as the code fires when DOM is ready, but the component isn't, the code doesn't work.
The problem is that I'm trying to get a DOM element this way:
document.querySelector(".slider-divisor")
I've tried putting this line in many places of the JS file (resources/META-INF/resources/slider-form-field.es.js) but the result is always null.
I've found a solution using setInterval that checks when the component 'appears' in the DOM. Then, the code is executed and setInterval stops, but I want to know if exists a way to check an event when component is loaded to execute my code instead use setinterval.
This is command I've used to create the module:
blade create -t form-field -c SliderFormField --js-framework react -p com.liferay.dynamic.data.mapping.form.field.type.slider slider-form-field
Thanks in advance.