jQuery UI Dialog Button Icons

后端 未结 12 1456
[愿得一人]
[愿得一人] 2020-11-29 02:40

Is it possible to add icons to the buttons on a jQuery UI Dialog? I\'ve tried doing it this way:

$(\"#DeleteDialog\").dialog({
    resizable: false,
    hei         


        
12条回答
  •  庸人自扰
    2020-11-29 03:27

    How about a class-based approach?

    In your _layout.cshtml file put something like the following:

    
    

    Then, in the file where you are creating the dialog, do something like this:

    $("#doStuff-dialog").dialog({
        title: "Do Some Stuff",
        modal: true,
        buttons: [
            {
                text: "Yes",
                class: "my-button-submit",
                click: function () {
                    $(this).dialog("close");
                }
            },
            {
                text: "No",
                class: "my-button-cancel",
                click: function () {
                    $(this).dialog("close");
                }
            }
        ],
        open: function () {
            stylizeButtons($("#doStuff-dialog").parent());
        }
    });
    

    Then you never have to rely on searching for text, and it requires a minimal amount of code in your dialog. I use this throughout my applications to apply jquery UI styling/icons to buttons just by giving them a class.

提交回复
热议问题