Infinite loop when calling hidden button via OnBlur

In a v10 web app I have a hidden button that is called using the following Javascript when an OnBlur is triggered via an Input widget:

"document.getElementById('"+OnBlurButton.Id+"').click();"

The hidden button runs a totally empty screen action (the code is yet to be added).

When the Input widget loses focus, the empty screen action is called as expected, however it ends up in an infinite loop, repeatedly running the empty screen action over and over again.

However interestingly, when debugging in the public area and running the website from a browser on someone else's machine, it just calls the empty screen action once as expected.

I have tried using different browsers on my machine and both end up repeatedly calling the action, so clearly it is something specific to my machine and not due to a browser plug-in for example.

Does anyone know what might be causing this behaviour?

Hi Sienna,

I've been through something identical, I even thought to put a flag to control the loop, but I ended up to use the onchange to call the hidden button and it solves.

Hope it solves :)

Hi Sienna, 

Did you try changing the calling method? Like, if it is set to Submit, changing it to Ajax Submit? 

Cheers

Hi Sienna,

Like Eduardo said, if the button is Submit, the page will refresh itself, and the onBlur might be retriggered.

The button is already Ajax Submit (I wish it was just that!).

Also can anyone tell me exactly how the OnChange works?  I couldn't find it in the documentation but I presume it would run every time a character is written in the Input widget, whereas OnBlur would run only after the widget loses focus.

I don't know if this helps, but I noticed that if I debug, it appears to run infinitely, however if I remove the break point and continue running it, and then put a break point back on it, it doesn't stop, suggesting it is not running continuously as it is no longer breaking in that action. But when I debug, I counted dozens of times before I removed the break point so is seemingly infinite when debugging.

Hi! Do your screen have more than one input field?


Yes.  Sorry, I should have mentioned, the Input widget is in a table in a web block that is inside another table inside another web block.

Sienna wrote:

The button is already Ajax Submit (I wish it was just that!).

Also can anyone tell me exactly how the OnChange works?  I couldn't find it in the documentation but I presume it would run every time a character is written in the Input widget, whereas OnBlur would run only after the widget loses focus.

you can change the trigger delay of an "On Change", by setting the osOnChangeTimerDelay javascript variable.
I think the default value is 800ms, you can try to change this value, with javascript statement in your eSpace javascript:   osOnChangeTimerDelay = 3200;

Hope it helps :)


Thanks for that, however it doesn't feel very elegant to use a timer because what happens if they're entering words they don't know how to spell for example and they take a long time to complete their input?  It just feels too rigid and limiting.

Also I'd really like to understand why the OnBlur is looping on my machine, is very curious....although a workaround could still suffice of course, but not convinced that this will work for what I'm doing.

Yours is complex situation.

 Go by baby steps. Perhaps create a screen with only that one web Block with the "onBlur" , the hidden button and another input field, no tables or other web blocks. Try to make this screen work and then start adding the other elements one by one and testing each situation. 

If you could not solve the situation, at least , you'll understand where is the problem. 

Hope this helps.

Graça

PS . The "on Blur" is a tricky event ... 

  

Thanks, I've already taken it out of the outer table and web block and had the same results but will strip it back further....

Ok so I added an input widget and the hidden onblur button set as ajax submit and it worked fine.

I then added the table from the base web block which has an input widget embedded in it and the onblur looped.

Both the first input widget and the one inside the table point to the same onblur button.

All the screen actions are empty except for the preparation which has an aggregate that feeds the table.

Curiously, when the table is on the same screen as the first input widget, then that also loops, but if I delete the table from the screen, then it stops looping.

I deleted all columns from the table except for the one with the input widget and the same thing happens.

How is it that the presence of the table causes a widget outside of the table, pointing to a button outside of the table, to loop or not loop depending whether it's on the screen?

And why is the table looping where there is nothing but an input widget on the table and all actions are empty?

And why does it not loop on another machine, only mine? It is my work laptop so I only have work related apps installed and it happens across browsers.

I had another colleague run it through the debugger on their machine and it doesn't loop!

This is very strange.
Please, are you using the same OS version, the same DotNet version and the same Service Studio version?

That last fact knock me down. Sorry. 

Ok so the plot thickens....

My colleague is on the exact same OS as me but is using Outsystems v10.0.1009.0 and I'm on v10.0.1013.0.

I got them to debug on their machine and they switched on debug in the public area, but it doesn't pause on any breakpoints when I run the app in my browser. I asked them to switch debugging off and on a couple of times as sometimes it's glitchy, and to make sure it was definitely in the public area not their personal area, but still it did not pause on any breakpoints when I was running it in my browser but did pause when they ran it.

Sienna,

Sorry for asking this, but are you sure you are running the same application? I mean, could be it possible that you are connected in a different environment? Or that both of you were with the application in the Public area (not in the personal area)?

Just to rule out this possibility.

Cheers.

I ran it in a different browser, still didn't stop on the breakpoints on my colleagues machine.

@Eduardo it only exists on one environment and we're both running and debugging in the public area.

Is it a "reactive" or "mobile" application?

This would explain why the debugger does not stop when you are using the application from your browser. The debugger needs a direct connection to the browser, so it only works with the browser it launches.

It's mobile not reactive.

Ok so I removed the aggregate that was feeding the table and replaced it with a local text list.

When I don't add anything to the list, the input widget NOT in the table does not cause the onblur to loop.

When I append a single piece of text to the text list in the preparation, then the input widget NOT in the table causes the onblur to continously loop.

Any ideas why this could be happening? And only on my machine and not others? Otherwise I think I'm going to have to open a support case.

Hello Sienna,

To help further, I think we would need a module that you could reproduce this, in order to evaluate if this happens for us as well.

But reaching support may be the final solution here...

I've opened a support case, thanks.

But the plot thickens further...

My colleague and myself are running the exact same Windows OS. I was running Outsystems v10.0.1013.0 and my colleague had v10.0.1009. The empty OnBlur action looped continuously on my machine but not on my colleagues (using the exact same module in the exact same environment).

My colleague upgraded to Outsystems v10.0.1013.0 and then the OnBlur looped continously on his machine too.

Both myself and my colleague rolled back to v10.0.1009.0.  It then stopped looping continuously on my colleagues machine but still was looping infinitely on mine.

Note that very oddy, using F9 in the debugger on my machine causes it to loop infinitely, however using F10 to step over causes it to only run twice through (but still don't understand why it's running twice and not once).

In addition, on both our machines, when entering data in the table, it is always returning the last row in the table no matter what row you click on. However when debugging, you can see that the table has different (and the correct) data for each row, but yet it ALWAYS says the current row in the last one in the list, regardless of which row you input the data.

Will see what Outsystems makes of it (I've shared the module with them, I didn't share it here partly because I'd need to strip it all out for client security/privacy, but mainly because I'm presuming it's unlikely anyone will experience the same problem unless running the same version).

Thanks to all for your time and suggestions, very much appreciated regardless of whether they made a difference or not!

Oh and I also tried upgrading to the latest version (10.0.1018.0) to no avail.