When press the "enter"-button on a mobile device I want to trigger an search action and close the keyboard. I get the '$ is not defined' error. My javascript knowledge is letting me down today. Can someone help me?
Did you removed the focus from the input? or focus other element?
Something like:
document.getElementById($parameters.MyInput).blur();
Alternatively you can find the Keyboard plugin on the community that allows you to close the keyboard programatically.
Cheers
Hey Martin,
That error means that you're trying to use jQuery without requiring the jQuery lib, so $ is not defined.
You much likely want something like this:
document.addEventListener('keypress', function myFunc(e){ if(e.which == 13) { $actions.MYACTION(); document.removeEventListener('keypress', myFunc); }});
Let me know if it worked.
EDIT: You probably don't want to remove the Listener there, maybe on blur you should remove the listener
Henrique Batista wrote:
The action does work, but the keyboard won't close.
Thaks for your help! It works fine now!
Hello guys, i found a good solution for this problem and i put on this topic:https://www.outsystems.com/forums/discussion/49343/close-iphone-ipad-keyboard-automatically-when-closing-modal/
See ya!