0

Can someone explain how I can change the CSS class on the button, for the standard JQuery UI dialog widget? My addClass() call is not working.

$("#dialog-message").dialog({
    modal: true,
    buttons: {
        Ok: function () {
            $(this).dialog("close");
            $(this).addClass("btn");
        }
    }
});
2
  • 1
    Post your HTML, please. Commented Oct 30, 2013 at 21:01
  • maybe you'll find this helpful: addClass in create function Commented Oct 30, 2013 at 21:23

2 Answers 2

1

To answer what you meant to ask, "Can someone explain how I can change the CSS class of a button for the standard JQuery UI dialog widget" there are a few ways. This is the most self-contained. Note that 'class' is encapsulated with single quotes. This is because IE breaks if it's not.

$("#dialog-message").dialog({
    modal: true,
    buttons:[
        {
            text: 'Ok', 
            'class': 'btn',
            click: function(){
                $(this).dialog("close");
            }
        },
        {
            text: 'Cancel', 
            'class': 'cancel',
            click: function(){
                $(this).dialog("close");
            }
        },
    ]
});
Sign up to request clarification or add additional context in comments.

Comments

0

The dialogClass seems to be what you are looking for

$("#dialog-message").dialog({
    modal: true,
    dialogClass: 'btn',
    ...

});

3 Comments

Thanks but that did not affect the class attached to the button
That might be what you meant to ask instead of what you asked!
This IS a correct answer, just not complete. Your dialog now has a class name, you can navigate to the button you wish since you can now reference any child elements!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.