Dialog Buttons

2 views
Skip to first unread message

Jonathan Sharp, Out West Media

unread,
Aug 27, 2009, 12:12:17 PM8/27/09
to jQuery UI Dev
I'd like to propose the following options for specifying buttons on the dialog.

buttons: [
{ id: 'button id',
label: 'The Label',
click: function() { ... },
priority: 'primary | secondary | default',
position: 'left | right',
icon: 'ui-icon',
iconPosition: 'left | right'
},
...
]

Cheers,
- Jonathan

Richard D. Worth

unread,
Aug 27, 2009, 7:19:38 PM8/27/09
to jquery...@googlegroups.com
Interesting. I'm wondering if the next change to dialog buttons shouldn't be to have them be jQuery UI Buttons? If the buttons have ids, maybe go directly to them with the button plugin for getting and setting their button properties? instead of going through dialog, which can instead just focus on creating the button pane.

- Richard

Scott González

unread,
Aug 27, 2009, 8:48:19 PM8/27/09
to jquery...@googlegroups.com
On Thu, Aug 27, 2009 at 7:19 PM, Richard D. Worth <rdw...@gmail.com> wrote:
Interesting. I'm wondering if the next change to dialog buttons shouldn't be to have them be jQuery UI Buttons? If the buttons have ids, maybe go directly to them with the button plugin for getting and setting their button properties? instead of going through dialog, which can instead just focus on creating the button pane.

What are you envisioning with this?

$('#dialog').dialog({
    buttons: [
        $('<button></button>').button({ ... }),
        $('<button></button>').button({ ... })
    ]
});

or:

$('#dialog').dialog({
    buttons: [
        '#foo',
        '#bar'
    ]
})
.find('#foo').button({ ... )
.end.find('#bar').button({ ... });

or something else?

Scott González

unread,
Aug 27, 2009, 9:00:12 PM8/27/09
to jquery...@googlegroups.com
There's an existing ticket to add this functionality: http://dev.jqueryui.com/ticket/4344

At this point it's really waiting on two things: 1) the button plugin, 2) deciding on an API for specifying buttons in a dialog.


On Thu, Aug 27, 2009 at 12:12 PM, Jonathan Sharp, Out West Media <jds...@outwestmedia.com> wrote:

Todd Parker

unread,
Aug 27, 2009, 9:06:18 PM8/27/09
to jquery...@googlegroups.com, jquery...@googlegroups.com
+1 on finishing the button plugin and using those in dialog so we can rake advantage of the full set of button options.

Richard D. Worth

unread,
Aug 28, 2009, 8:15:51 AM8/28/09
to jquery...@googlegroups.com
Something like that. Of course that brings up the pain point of having to go to the dialog container (ui-dialog) to be able to .find the buttons.

- Richard

2009/8/27 Scott González <scott.g...@gmail.com>

Jonathan Sharp, Out West Media

unread,
Aug 28, 2009, 10:04:49 AM8/28/09
to jquery...@googlegroups.com
2009/8/27 Scott González <scott.g...@gmail.com>
I would think that the button dialog would pass through the button options internally. So something similar to:

buttons: [{ ... }, { ... }]

and then internally as dialog iterates to create the buttons: $('<button></button>').button({options});

This would also facilitate allowing any additional attributes for buttons that would be specific to dialogs. Such as if you could specify either right or left foating.

- Jonathan
 

Richard D. Worth

unread,
Aug 28, 2009, 11:49:35 AM8/28/09
to jquery...@googlegroups.com
But then to change a button after you init the dialog with three buttons, do you got through dialog.buttons, or do you go directly to the button, for example, by $('#id').button('option', ... ? And if you do go through dialog.buttons, how do you get and set just one button entirely. And how do you get and set single and multiple options on just one button (of 3)?

- Richard

Jonathan Sharp, Out West Media

unread,
Aug 28, 2009, 1:03:31 PM8/28/09
to jquery...@googlegroups.com
I think in this case it may make sense to go through the dialog as such:

$('#dialog').dialog('getbutton', 'id').button('label', 'New Label');

- Jonathan

Richard D. Worth

unread,
Aug 28, 2009, 1:25:58 PM8/28/09
to jquery...@googlegroups.com
Or

$('#dialog').dialog('button#id').button('label', 'New label');

:)

- Richard

maestrosgr

unread,
Sep 20, 2009, 6:41:26 AM9/20/09
to jQuery UI Development
Is there a way to change the buttons (add,remove,change title, change
functionality) AFTER I init the dialog?

On Aug 28, 8:25 pm, "Richard D. Worth" <rdwo...@gmail.com> wrote:
> Or
>
> $('#dialog').dialog('button#id').button('label', 'New label');
>
> :)
>
> - Richard
>
> On Fri, Aug 28, 2009 at 1:03 PM, Jonathan Sharp, Out West Media <
>
> jdsh...@outwestmedia.com> wrote:
> > I think in this case it may make sense to go through the dialog as such:
>
> > $('#dialog').dialog('getbutton', 'id').button('label', 'New Label');
>
> > - Jonathan
>
> > On Fri, Aug 28, 2009 at 10:49 AM, Richard D. Worth <rdwo...@gmail.com>wrote:
>
> >> On Fri, Aug 28, 2009 at 10:04 AM, Jonathan Sharp, Out West Media <
> >> jdsh...@outwestmedia.com> wrote:
>
> >>> 2009/8/27 Scott González <scott.gonza...@gmail.com>

Richard D. Worth

unread,
Sep 21, 2009, 4:46:12 AM9/21/09
to jquery...@googlegroups.com
For now, you have to replace all the buttons at once by passing a new buttons hash

$('#dialog').dialog('option', 'buttons', { ... });

- Richard
Reply all
Reply to author
Forward
0 new messages