Set "Default" button programmatically
2219
Views
12
Comments
On our RadarOn our Radar
Frontend (App Interfaces)
Sometimes you have two buttons that you want to have as the "Default" button based on different conditions. For example, if you have a screen with basic and advanced search, you want the "Search" button to be the default button, but you have a different "Seach" button in the If.

J.Ja
This would be great!

+1

This would be super great to have.

That should already be possible with some JavaScript. After all, the default button is a client-side behavior.

There's more to it than just the behavior, there is also styling that comes with it too.

J.Ja

The style is the easier part - it can be easily applied by adding the Is_Default class name to the button. This works for submit buttons and for links as well.

The handling of the enter key should be a little trickier. But it could be done by including a "dummy" default button, and then writing the onclick extended property to delegate the click on the real (programmatically calculated) default button. Something along these lines:

onclick = "$('#" + RealDefaultButton.Id + "').click(); return false;"

Point is, this is a lot of work to do when they could just make this easy on us. :)

J.Ja

True! Especially considering how many of the other Attributes of Widgets can simply have expressions that resolve to Booleans in them.

We need this

I Agree with Justin. Turn it more easy for ud !

I also need this feature! Had to make some javascript code to bypass the lack of control of the default behaviour.

Hi Justin,

In reactive apps default buttons work for the inputs inside the forms the buttons are in (very similar to the HTML spec).  This means that you can have multiple default buttons on a screen and the clicked button depends on what input widget has the focus.


Does this solve the requirement (on reactive apps)?

Thanks,
Tiago Simões