Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add class to jquery dialog buttons

Tags:

I want to add css class on buttons of a jquery dialog box.

Here is my code :

$(document).ready(function(){       $('#messageBox p').html('bla bla bla. Ok?');        $('#messageBox').dialog({         modal : true,         buttons: {           'Yes': function() {             doSomething();             $(this).dialog('close');           },            'No': function() {             doAnotherThing();             $(this).dialog('close');           }         }       });     }); 

For example, I would like add ".red" class on my "yes" button.

How can I do that?

Thank you!

like image 807
nicosomb Avatar asked Sep 24 '09 13:09

nicosomb


2 Answers

buttons: [             {                text: "Submit",                "class": 'submit_class_name',                click: function() {                                        $(this).dialog("close");                 }             },             {                text: "Cancel",                click: function() {                    $(this).dialog("close");                 }             }           ] 
like image 95
spin Avatar answered Sep 20 '22 20:09

spin


I've got the solution, thanks to Rich :

$(document).ready(function(){       $('#messageBox p').html('bla bla bla. Ok?');        $('#messageBox').dialog({         modal : true,         dialogClass: 'dialogButtons',         buttons: {           'Yes': function() {                 doSomething();                 $(this).dialog('close');           },            'No': function() {                 doAnotherThing();                 $(this).dialog('close');           }         }       });     }); $("div.dialogButtons div button:nth-child(1)").addClass("oneCssClass"); $("div.dialogButtons div button:nth-child(2)").addClass("anotherCssClass"); 

Solved!

like image 27
nicosomb Avatar answered Sep 21 '22 20:09

nicosomb