I'm using two buttons from the SilkUi in my webpage which are both set to default = no. If I press enter in the screen, the buttons don't activate, which is the desired behavior.

However, I also have input widgets in the same page. When I click in one of these and then press enter, the first button on the page activates. So when I'm editing a field and press enter, the first button on the page activates.

My current solution is a hidden button with an ajax submit action that does nothing at all. However, this is not a clean solution, and the user sees a 'loading' icon after pressing it quickly a couple times. That means the user might think their input was saved, while it will only be saved on the press of the 'save' button.

Hello Rob,

Sorry, but I don't understand your question.

First, the only way I know to have two default buttons in a screen (OutSystems way) is through the use of Web Blocks. How is you setting both buttons as default at the same time, as when you set the Is Default property of one, any other in the same unit (screen or web block) will be deactivated?

Second, yes, the behavior is that. If you have a default button in the page, when you press enter and an input has focus, it will be clicked.

If you don't want this behavior, just don't set any default button in the page.

But it is good practice to have a default button. And in a Form page (detail screen), it is common for the SAVE button to be the Default one. And you validate if the info is there before trying to save data and if something is not ok, you alert the user.

What exactly you want to achieve?

Cheers.

Eduardo Jauch wrote:

Hello Rob,

Sorry, but I don't understand your question.

First, the only way I know to have two default buttons in a screen (OutSystems way) is through the use of Web Blocks. How is you setting both buttons as default at the same time, as when you set the Is Default property of one, any other in the same unit (screen or web block) will be deactivated?

Second, yes, the behavior is that. If you have a default button in the page, when you press enter and an input has focus, it will be clicked.

If you don't want this behavior, just don't set any default button in the page.

But it is good practice to have a default button. And in a Form page (detail screen), it is common for the SAVE button to be the Default one. And you validate if the info is there before trying to save data and if something is not ok, you alert the user.

What exactly you want to achieve?

Cheers.

I am sorry, I have two buttons that are both set to default = no. Changed the op to this to avoid any further confusion.


Hi Rob,

Check the solution of this post

Regards,

Marcelo

rob knipscheer wrote:


I am sorry, I have two buttons that are both set to default = no. Changed the op to this to avoid any further confusion.


Hi Rob,

Are you sure you don't have any other element (button or "link") set to Default?

What is the browser you are testing? What version (O10)? Do you have any small module you can share that reproduces this behaviour? (this is not normal).

Cheers.

EDIT: As it was pointed, this IS normal behavior.

Hi rob,

If you really want to do that, there's a way, but it's not a good practice as Eduardo said.

The behaviour that you are struggling with is HTML's default behaviour. When you press "Enter", the HTML will look for the default button and if none is found, it will look for the first button in the "tree order".

Taking this into consideration and if there's no other way, what you can do is replace your buttons for a link with text inside and apply "Button Is_Default" to your "default" buttons and "Button" to the other ones. This way you will accomplish what you desire, but I will repeat THIS IS NOT RECOMMENDED.


I'd recommend to go a middle way and have no default buttons in your web blocks and only apply the Is_Default css class to the ones you desire and to have a Default button in your page.


Gabriel 


lol

Thanks for the correction, Gabriel. Never noticed that the browser would look for the first button in case no Default button is found :/ Damn...
But them, I always have a default button, rs

In this case, Marcelo pointed to the right topic, if you really does not want a Default button.

I still advocate to have one.

Cheers.

EDIT: A possibility is to DISABLE the Save/Send/etc button while there is still missing information (but you will need extra logic to do that). You can also set Client & Server validation and this will allow the data to be sent ONLY if the mandatory and data types are correct, but I don't like this approach.

The solution that I had implemented is simply a hidden button that 'catches' the enter press because it's the first button on the page. I do not want any button as default, as the user has to fill many input fields and they are prone to press enter after filling one.

Thanks for helping

You should consider (if possible) splitting the form and use a Wizard pattern, for example, to improve the User Experience (UX/UI).

Cheers.