Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added "icons" option for UI Dialog buttons #822

Closed
wants to merge 3 commits into from

3 participants

Dmitry V. Alexeev Jörn Zaefferer Scott González
Dmitry V. Alexeev

It allows you to add custom icons for dialog buttons.
You can see example here: http://jsfiddle.net/alexeevdv/g5pYa/

Jörn Zaefferer
Owner

This overlaps with #423, which also forwards a "showText" property. I think what we really need is a way to customize all button options, especially since button is becoming a required dependency for dialog (when using the buttons option).

Dmitry V. Alexeev

i added a list of allowed button options which will be trimmed from common options. if text is not specified or false it will not shown. You can see it on example page: http://jsfiddle.net/alexeevdv/g5pYa/

Scott González

The problem with having a pass-thru to the buttons API is that we currently have a pass-thru to .attr() and they don't mix well. There was already a discussion about this in http://bugs.jqueryui.com/ticket/6830 and the best API seems to be showText and icons in addition to full support of .attr().

Jörn Zaefferer
Owner

Buttons should always have text, so closing this in favour of #423. Which I'm probably not going to merge either, as it doesn't have tests and needs to be rebased on the dialog branch.

Jörn Zaefferer jzaefferer closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 17 additions and 2 deletions.
  1. +17 −2 ui/jquery.ui.dialog.js
19 ui/jquery.ui.dialog.js
View
@@ -334,7 +334,7 @@ $.widget("ui.dialog", {
}
if ( hasButtons ) {
$.each( buttons, function( name, props ) {
- var button, click;
+ var button, click, options;
props = $.isFunction( props ) ?
{ click: props, text: name } :
props;
@@ -345,10 +345,25 @@ $.widget("ui.dialog", {
props.click = function() {
click.apply( that.element[0], arguments );
};
+ // Copy allowed button options from given properties
+ options = {};
+ optionsList = ["icons","disabled","label"];
+ for ( var i in optionsList) {
+ if (props[optionsList[i]]) {
+ options[optionsList[i]] = props[optionsList[i]];
+ delete props[optionsList[i]];
+ }
+ }
+ // if no text specified
+ if (!props.text || props.text == "") {
+ options.text = false;
+ props.text = false;
+ }
+
button = $( "<button></button>", props )
.appendTo( that.uiButtonSet );
if ( $.fn.button ) {
- button.button();
+ button.button(options);
}
});
this.uiDialog.addClass( "ui-dialog-buttons" );
Something went wrong with that request. Please try again.