Add custom buttons to titlebar

1,958 views
Skip to first unread message

r00tk1ll

unread,
Jun 29, 2009, 12:49:53 PM6/29/09
to jQuery UI Development
How would I go about adding a custom button next to the 'x' close
button on the title bar? I am trying to add a '-' minus button that
will "minus" the dialog, not destroy it. Ideas?

Thanks

Scott González

unread,
Jun 29, 2009, 2:32:25 PM6/29/09
to jquery...@googlegroups.com
var dialog = $(el).dialog();
var titlebar = dialog.parents('.ui-dialog').find('.ui-dialog-titlebar');

$('<button>minimize</button>')
    .appendTo(titlebar)
    .click(function() {
        dialog.toggle();
    });

r00tk1ll

unread,
Jun 29, 2009, 3:51:42 PM6/29/09
to jQuery UI Development
You're good man, Ill give it a shot.

Thanks

On Jun 29, 1:32 pm, Scott González <scott.gonza...@gmail.com> wrote:
> var dialog = $(el).dialog();
> var titlebar = dialog.parents('.ui-dialog').find('.ui-dialog-titlebar');
>
> $('<button>minimize</button>')
>     .appendTo(titlebar)
>     .click(function() {
>         dialog.toggle();
>     });
>

r00tk1ll

unread,
Jun 29, 2009, 4:08:15 PM6/29/09
to jQuery UI Development
Nice, First try works like a charm, thanks again

r00tk1ll

unread,
Jun 29, 2009, 5:11:31 PM6/29/09
to jQuery UI Development
You wouldn't happen to know how to hide the entire dialog on minimize
would you? I still want it to be active just not displayed. Tried $
('#dialog').css("display","none"); to hide the container div "#dialog"
but it doesn't hide the titlebar or buttons??

On Jun 29, 1:32 pm, Scott González <scott.gonza...@gmail.com> wrote:
> var dialog = $(el).dialog();
> var titlebar = dialog.parents('.ui-dialog').find('.ui-dialog-titlebar');
>
> $('<button>minimize</button>')
>     .appendTo(titlebar)
>     .click(function() {
>         dialog.toggle();
>     });
>

Scott González

unread,
Jun 29, 2009, 7:37:33 PM6/29/09
to jquery...@googlegroups.com
You have to hide the generated wrapper $('#dialog').parents('.ui-dialog');

r00tk1ll

unread,
Jun 30, 2009, 5:22:49 PM6/30/09
to jQuery UI Development
Thanks for all your help guys, here is my combination that seems to be
working for me... Just in case someone else wants to know how to do
this:

var closeBtn = $('#dialog').parents('.ui-dialog').find("a.ui-dialog-
titlebar-close");
$(closeBtn).after('<span class="ui-icon ui-icon-minusthick">minus</
span>'); /* this adds the minus icon from the theme set */

$('.ui-icon-minusthick').click(function() {
$("#dialog").parents('.ui-dialog').css("display","none");

}); /* This hides the dialog, haven't figured out how to call it back
up yet */

On Jun 29, 6:37 pm, Scott González <scott.gonza...@gmail.com> wrote:
> You have to hide the generated wrapper $('#dialog').parents('.ui-dialog');
>
Reply all
Reply to author
Forward
0 new messages