Jquery Dialog добавить пользовательский класс для кнопки

0

Я хочу добавить определение класса в элемент, созданный с помощью button: { } как это сделать, не делая что-то вроде $('.ui-dialog-buttonpane button:eq(0)')

http://jsfiddle.net/3zcEY/

     $(function() {
            $( "#dialog-confirm" ).dialog({
              resizable: false,
              height:140,
              modal: true,
              buttons: {
 //add a class definition to the delete all items button here. tried  
//class:'save' didn't work

                "Delete all items": function() {
                  $( this ).dialog( "close" );
                },
                Cancel: function() {
                  $( this ).dialog( "close" );
                }
              }
            });
          });
Теги:
dialog

1 ответ

2
Лучший ответ

Вы можете использовать объект option для указания имени класса.

$("#dialog-confirm").dialog({
        resizable: false,
        height: 140,
        modal: true,
        buttons: {
            //add a class definition here.
            "Delete all items": {
                'class': 'customClass', //<-- specify the class here
                text: 'Delete all items', //<-- text for the button
                click: function () { //click handler
                    $(this).dialog("close");
                }
            },
            Cancel: function () {
                $(this).dialog("close");
            }
        }
    });

скрипка

Ещё вопросы

Сообщество Overcoder
Наверх
Меню