Default button equivalent in v10

Default button equivalent in v10

  

Hi,

In our app we used to use default button parameter that was triggered when user clicked enter on software keyboard. However on mobile app v10 there is no such attribute. Is it possible to bind "enter" click on phone keyboard to trigger button click?

Our use case is that there is only two input fields and one button on the page and it is way faster to input data and click "enter" then click "done" and click button... 


Thank you for any advice.


Hi Mykola,

Do the following.

1) Place your inputs inside a form.

2) On the form add an "onsubmit" event and bind a client action (named: "OnSubmit")

3) On that OnSubmit client action place a JS Node with the following (to prevent a navigation)

window.event.preventDefault();

3) Call the button OnClick action on the OnSubmit client action 

Hi João,

I've tried this and it didn't work at all.. the "onsubmit" is not on the suggested list of form events so I've put it manually and also added alert to see if OnSubmit event is triggered. But not on device nor the browser clicking "enter" doesn't trigger this event. 

Service Studio only displays some suggestions but supports the majority of all HTML5 elements attributes.

I did this example and it works. Check out:

Hi João,

I think what Mykola want is to use enter button on mobile phone keyboard to submit the form.

Is using window.event.preventDefault() on OnSubmit event can achieve this functionality?

I tried this on Common\Login screen, and it's not working.

Thanks.


Hi,

I have tried the solution suggested by João but it only partially works. When the 'enter' button is used validations are performed and any errors are displayed, however, when everything is OK, navigation to the next screen does not take place. Any suggestions on how to solve this problem?

You have to do the next couple of things:

  • Use a form on the page;
  • Within the form define a button and add 'type'"submit"' as an attribute:
  • Add an event to the button and in its action, use the javascript mentioned above:

Wouter Baeten wrote:

You have to do the next couple of things:

  • Use a form on the page;
  • Within the form define a button and add 'type'"submit"' as an attribute:
  • Add an event to the button and in its action, use the javascript mentioned above:


Many thanks Wouter! Also adding a button with type "submit" did the trick.