Changing the action button labels of a OO.ui.confirm dialog

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing the action button labels of a OO.ui.confirm dialog

Egbe Eugene
Hi All,

while going through OO.ui.confirm dialog documentation I got curious about
how to change the labels of the action buttons 'Ok' and 'Cancel' to show
different texts.

--
Eugene
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Changing the action button labels of a OO.ui.confirm dialog

Derick Alangi
Hi,

Yes, it's possible to personalize the action labels via the `*actions`*
option when constructing your message dialog. Wrote up something on this
etherpad: https://etherpad.wikimedia.org/p/wrDQW6gSAqwWYwfL2tJb. Hope it's
useful.

*--*
*Derick*


On Thu, Dec 12, 2019 at 9:40 AM Egbe Eugene <[hidden email]> wrote:

> Hi All,
>
> while going through OO.ui.confirm dialog documentation I got curious about
> how to change the labels of the action buttons 'Ok' and 'Cancel' to show
> different texts.
>
> --
> Eugene
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Changing the action button labels of a OO.ui.confirm dialog

Derick Alangi
Note: With the `confirm()` method, a MessageDialog object is being created
in the background. Altering that dialog at run time is almost impossible.
So, the best way is go with constructing your own Message Dialog with the
action labels you want as I shared above or other ways.

For more information from the JS side, see:
https://stackoverflow.com/questions/823790/javascript-confirm-popup-yes-no-button-instead-of-ok-and-cancel
and
other Google Search related results.

*--*
*Derick*


On Thu, Dec 12, 2019 at 10:41 AM Derick Alangi <[hidden email]>
wrote:

> Hi,
>
> Yes, it's possible to personalize the action labels via the `*actions`*
> option when constructing your message dialog. Wrote up something on this
> etherpad: https://etherpad.wikimedia.org/p/wrDQW6gSAqwWYwfL2tJb. Hope
> it's useful.
>
> *--*
> *Derick*
>
>
> On Thu, Dec 12, 2019 at 9:40 AM Egbe Eugene <[hidden email]> wrote:
>
>> Hi All,
>>
>> while going through OO.ui.confirm dialog documentation I got curious about
>> how to change the labels of the action buttons 'Ok' and 'Cancel' to show
>> different texts.
>>
>> --
>> Eugene
>> _______________________________________________
>> Wikitech-l mailing list
>> [hidden email]
>> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
>
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Changing the action button labels of a OO.ui.confirm dialog

Bartosz Dziewoński
In reply to this post by Egbe Eugene
You can actually customize the labels in OO.ui.confirm() too:

        OO.ui.confirm( '...', {
                actions: [
                        { action: 'accept', label: 'Yes!', flags: 'primary' },
                        { action: 'reject', label: 'No…', flags: 'safe' }
                ]
        } ).done( function ( confirmed ) {
                ...
        } );

Make sure to keep the `action: 'accept'` and `action: 'reject'` (the
dialog uses this to make the two buttons do things), the other pieces
can be changed.

--
Bartosz Dziewoński

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Changing the action button labels of a OO.ui.confirm dialog

Egbe Eugene
Thanks very much for the suggestions.

On Fri, Dec 13, 2019 at 5:05 PM Bartosz Dziewoński <[hidden email]>
wrote:

> You can actually customize the labels in OO.ui.confirm() too:
>
>         OO.ui.confirm( '...', {
>                 actions: [
>                         { action: 'accept', label: 'Yes!', flags:
> 'primary' },
>                         { action: 'reject', label: 'No…', flags: 'safe' }
>                 ]
>         } ).done( function ( confirmed ) {
>                 ...
>         } );
>
> Make sure to keep the `action: 'accept'` and `action: 'reject'` (the
> dialog uses this to make the two buttons do things), the other pieces
> can be changed.
>
> --
> Bartosz Dziewoński
>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l