HTML/JavaScript Snippet does not execute properly inside modals

I am converting content of text widget inside a modal page to URL’s by replacing text with <a> tags. I have set the widget to to JavaScript with jQuery. Widget is placed inside a page with modal layout so the page opens up as a modal. The JavaScript snippet should be executed whenever modal is opened. On opening modal for first time, script is executed but after this it is not until page is refreshed. Closing the modal and opening it again does not trigger the script execution, but everything else inside modal is working and properly loaded. The widget works only after a page refresh in this scenario. When modal is opened after refreshing the page, all text containing links is converted to URL. If I open the modal page containing snippet widget multiple times, then that text remains text and script is not executed to convert it into URL’s. I have tested the jQuery code in chrome console too, it is working. But  looks like script is not triggered every time the modal is opened.  Modal is actually View page of an entity with Atlas popup modal layout. It is opened from control bar button of a data grid. Button is also set as default button Have tried refresh with context change/update options in the widget. It does not work. Tried with on load functions for modal but didn't work All code is inside document.ready function   The above scenario is applicable to Mendix sandbox environment (Run in cloud for free app). It works fine locally. Script is executed on each modal load when run locally. Mendix v8.10.0
1 answers

Hi Umar,

Maybe your script runs too early? I found it quite hard to detect when a mendix page is fully loaded to determine when a java script widget should fire. Try setting a timeout  

setTimeout(function(){  }, 3000);

around that java script. the document.ready function did not work reliably for my case when I needed it..


Edit: of course setting a timeout is not reliable either as it still depends on your page loading, but it is nice to check and maybe find the culprit