0

I am trying to write custom class in dialog box button. I am unable to do do that it is not taking custom css class at all. My code is as follows:

function AddProcedures() { 
    success: function(msg) {
        if (msg.status) {
            $("#modal_Window").dialog({
                title: 'XX',
                buttons: {
                    Close: function() {
                        $(this).dialog('close');
                    }
                },
                open: function() {
                    //debugger;
                    $('.ui-dialog-buttonpane').find('button:contains("Close")').removeClass("ui-button-text-only");
                    $('.ui-dialog-buttonpane').find('button:contains("Close")').removeClass("ui-button-text-only").parent().addClass('ButtonLong');
                    $('.ui-dialog-buttonpane').find('button:contains("Close")').addClass("ButtonLong");
                },
                modal: true
            });
            $("#modal_Window").html('MM');
        }
        error: function(msg) {
            ErrorDialog('@RelatedProcedure.ProcedureTitle', '@RelatedProcedure.Error');
        }
    });
}

I have spent one full day to do it. I may not expert in Jquery. Please help me.

2
  • 1
    Please post html css or Create a fiddle and give me link Commented Jul 5, 2013 at 8:56
  • You appear to have an extraneous ) on the second-to-last line. You may want to check that you've posted all the relevant code. Commented Jul 5, 2013 at 9:00

4 Answers 4

1

You can try this. It worked for me. I just made four CSS group styles to style the buttons

button[type="button"].ConfirmButton 
button[type="button"].ConfirmButton:hover 
button[type="button"].CancelButton 
button[type="button"].CancelButton:hover

and this is the JavaScript:

var ModalDiv = $(document.createElement("div"));

$(ModalDiv).html('Are you sure you want to delete this note from the request?');

$(ModalDiv).dialog({
    modal: true,
    resizable: false,
    draggable: false,
    closeText: "",
    hide:{
              effect: "fade",
              delay: 0,
              duration: 250,
              easing: 'linear'
          },
    show: {
              effect: "fade",
              delay: 0,
              duration: 250,
              easing: 'linear'
          },
    width: 400,
    title: "Tile of Dialog",
    dialogClass: "ui-dlgconfirmation",
    buttons: [{
                  text: "Delete",
                  class: "ConfirmButton",
                  click: function () {
                      $(this).dialog("close");
                  }
              },
              {

                  text: "Cancel",
                  class: "CancelButton",
                  click: function () {
                      $(this).dialog("close");
                  }
              }]
});

With 
Sign up to request clarification or add additional context in comments.

Comments

0

Yes simply while adding button,add the class name

Close   : {

              class: 'yourNewClassname', click: function() {

               //on click

            },

1 Comment

I have tried ur code It is giving MS Visual studio error (80020101) from line (t&&g.test(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t) ) under Jquery-1.8.3.min.js file.
0

you can override css styles with jQuery or javascript.

Just try something like this :

$(document).ready(function()
{
    $('theTargetedIdentifier').css({'font-size':14});
});

1 Comment

I am using Modal Dialog Box in MVC3 using Jquery.
0

Try to override the css styles by like the css below

#popupid .ui-button-text-only{
 . . . . 
. . .  . .
font-size:14px;
. . . . 
. . .  . .
}

you can use the button id or class for specify conditional css

Comments

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.