Run "onChange" client script with delay (like autocomplete in reference fields)

nikita_mironov
Kilo Guru

I need an "onChange" Client Script to run over task.short_description field following several milliseconds after user completes data entry. Similar to autocomplete in reference fields - system should wait 250-500 milliseconds after user puts the last letter in short_description and then fire the Client Script. Can you please give me a hint where to dig?

3 REPLIES 3

Mark Stanger
Giga Sage

The onChange will run as the field changes so you can't change the timing of that event specifically. You might be able to get the right timing within that event by using the 'setTimeout' function to introduce a small delay. Details on setTimeout can be found here.

http://www.w3schools.com/jsref/met_win_settimeout.asp


nikita_mironov
Kilo Guru

Thanks Mark and all for pointing me to the right direction!
This thing (part that starts "without globals") helped me to do the trick:
http://stackoverflow.com/questions/1381751/onkeyup-javascript-time-delay


shallom
Tera Contributor
try this
setTimeout(funName, 
1000);
function funName() {}