This thread is resolved. Here is a description of the problem and solution.
Problem:
If you're experiencing issues with JavaScript not functioning correctly on translated pages using the Elementor HTML widget, it might be due to WPML's Translation Editor not handling large JavaScript blocks well. This can result in modified or escaped scripts, causing them to stop working.
Solution:
We recommend moving the HTML and JavaScript code out of the Elementor HTML widget and registering it as a WordPress shortcode or a small custom plugin. Here's a step-by-step guide:
1. Add the following code to your theme's functions.php file:
function hotel_spider_form_shortcode() {<br /> ob_start();<br /> ?><br /> <!-- Place your complete HTML, CSS and JavaScript here --><br /> <?php<br /> return ob_get_clean();<br />}<br />add_shortcode( 'hotel_spider_form', 'hotel_spider_form_shortcode' );2. Replace the full HTML and JavaScript in the Elementor HTML widget with the shortcode:
[hotel_spider_form]
This approach ensures that WPML only translates the page content, while the JavaScript is generated by WordPress and remains consistent across all languages. It also simplifies maintenance, as future changes only need to be applied in one place.
If this solution does not resolve your issue or seems outdated, please check the related known issues, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. If the problem persists, we highly recommend opening a new support ticket at WPML support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
This topic is split from https://wpml.org/forums/topic/span-html-elements-added-all-accross-the-translated-pages/