Input "On Change" is too fast

Input "On Change" is too fast

  
Hi,

I have an input with an "On Change" destination, but it triggers too fast. (around 1-2 sec.)

What ends up happenning is this: 
        - User wants to type 12.50
        - Types "12" and looks at the paper
        - Types ".50", but it replaces the "12"


Is there a way (argument?) to delay the trigger a couple of seconds? Another (better) way to overcome this?

Thank you.
Hi Cristovão,

Have you tried to use the onkeyup event instead?
You can even do something like:

$('#element').bind('keyup', function() { alert('hello world!!') } );
You can also do

             $('element').keyup(function() { });


Note that in jQuery, the letters 'on' are removed from all functions.

Best Regards,

Gonçalo M.

Hi Cristovao,
 
Actually, using onblur would be the best solution for that case.
Whenever the control loses focus, you save the data. See here.

:)
Yeah, wish it would be a standard option in the properties of an input-widget to be able to use OnBlur instead of OnChange.
Solution

Hi Cristovao!


You can change the trigger delay of an "On Change", by setting the osOnChangeTimerDelay javascript variable.

The default value is 800, that corresponds to a delay of 800 ms after the user stops typing.


To change this value to 3 seconds, you just have to include the following javascript statement in your eSpace javascript.


osOnChangeTimerDelay = 3000;


Thanks!

Solution
Thanks everyone. 

Ended up using "onblur" with "document.getElementById('" + bt n_name.Id + "').click();"

Took me a while to realize had to keep "Visible" as True and use style to hide it... but it's working fine now.
Hello Guys,

I've tried to do exactly the same and, at least on platform 9.1, the correct variable to use is osOnChangeTimerDelay instead of the mentioned osOnChangeTimeDelay.

Cheers,

Hi Pedro,

That's what Ricardo also mentioned, he just made a typo in the example.
Just to ensure! =)

Any idea if a similar setting kan be used in a P10 generated application ? Setting the timer variable does not work in that setup unfortunately, it also uses a very short timeout.

Ricardo Ferreira wrote:

Hi Cristovao!


You can change the trigger delay of an "On Change", by setting the osOnChangeTimerDelay javascript variable.

The default value is 800, that corresponds to a delay of 800 ms after the user stops typing.


To change this value to 3 seconds, you just have to include the following javascript statement in your eSpace javascript.


osOnChangeTimerDelay = 3000;


Thanks!


Hi Ricardo, sorry for my ignorance, where can I find & change the osOnChangeTimerDelay javascript variable, could you show me a screenshot? I cannot seem to find it anywhere, sorry I'm a newbie with a personal environment only. Thanks.

Hi Andre,

It's a JavaScript variable, so it's not directly available in Service Studio. But if you start a Web App, and use your browser's devtools, you can query the variable:

If you want to change it, you'll need to write some JavaScript yourself.

Should that variable be visible in a mobile app? If I debug a mobile app in chrome and inspect with chrome dev tools, I cant see that variable. Would be good to lengthen it a bit if poss!

Hi Danny,

No, the variable is probably not available to mobile apps. But with mobile apps you have also access to onblur, which might suite you better? 

I am literally working on doing that right now Kilian, thanks!!!

Hi Kilian, sorry to keep pressing for this but I am still learning the platform and I am not a developer, could you explain how to implement the javascript in espace to the suggested 3 seconds..

osOnChangeTimerDelay = 3000;

I have not found were I can add javascript in the espace and how ot implement this code. thanks

Hi André,

For Mobile Apps, adding JavaScript is as simple as using the JavaScript Statement:

Since they are part of the flow, they can interact with the rest of the code via Input and Output Variables. This is probabably what you want for the osOnChangeTimerDelay.

Larger scripts can be added in the Scripts Folder on the Interface tab. These are typically .js files that you want to include rather than smaller stuff written yourself. Note that there's no input/output here, so they must be self-contained. To include them in a Screen, select them in the Required Scripts Property of the Screen.

Hi Kilian,

Sorry, you are talking to a newbie (both OS and JS). Could you explain "baby steps" what exactly I need to do.

I have an email input field with a On Change action to validate the email address.  
Problem is this tries to validate the address too fast.


Here is what I have attempted to do so far (but failed):



Help?

The osOnChangeTimerDelay is a setting that (apparently, I'm going by Ricardo's information here) changes the time it takes for the Platform to fire an onchange event. So you need to set that once (per Screen, probably).

What you have attempted to do is calling the delay setting function after the onchange has fired, which of course is not what you need to do. Also, you gave the JavaScript function the same name as the variable, and I'm not very proficient in JavaScript, but I think that's not a good idea...