likemike Posted July 1, 2022 Share Posted July 1, 2022 Hello! Since 3 days I'm trying to solve a strange behaviour of UnimURLFrame in combination with JavaScript. I've prepared 2 test cases to show what I mean. The test cases have both a little HTML (for displaying a button) and a file named error.js which assigns to the button an event and starts an AjaxRequest. Each call of the JS-file shows a "Test"-message in the console as well. Because of that, you have to start the test case and press F12 to see the console. The first test case has only the Mainm-form. When you start it, there is one "Test"-message in the console. If you press the "Start"-button nothing else happens. The second test case has another form, which is called by the button on the Mainm-form. When you start it and you press the button on the main form there is one "Test"-message in the console (equal to the 1st test case). If you press the "Start"-button, another "Test"-message appears (so the JavaScript is executed a second time). Why? This causes al lot of side effects and my app doesn't work as it should. I've tried a lot of "tricks" to prevent the 2nd execution, but nothing worked for me. Any help would be appriciated Unigui1.rarUnigui2.rar Link to comment Share on other sites More sharing options...
Norm Posted July 5, 2022 Share Posted July 5, 2022 It looks like what you are experiencing is a bug in the TUnimForm (or TUnimURLFrame) component. What is happening is that when the OnAjaxEvent is executed the first time, the htmlFrame is reloaded to the browser a second time, resulting in the associated java code being executed again. There is nothing you can do to work around it. You should probably report it as a bug that needs fixing. This behavior does not occur with TUniForm (non-mobile). I have duplicated your project for Desktop and it works as expected. I have uploaded the project below. Project3.zip Link to comment Share on other sites More sharing options...
likemike Posted July 5, 2022 Author Share Posted July 5, 2022 @Norm: Thank you for testing! I've already suspected UnimURLFrame to cause this faulty behaviour. @Sherzod: Could you please open a ticket for that "bug"?! Link to comment Share on other sites More sharing options...
Sherzod Posted July 5, 2022 Share Posted July 5, 2022 Hello @likemike I don't see the bug yet. Link to comment Share on other sites More sharing options...
likemike Posted July 5, 2022 Author Share Posted July 5, 2022 As Norm has described, the HTML-code is reloaded when executing an Ajax-Event. Therefore the JS is executed unnecessarily a second time. For example: you can't use "const" in JS, because when it's executed more then once an error occurs (because you can't redefine "const"). For me that's a bug and the fact, that it's working correct on desktop-version approves that. Link to comment Share on other sites More sharing options...
Recommended Posts