jQuery UI Dialog Button Icons

后端 未结 12 1476
[愿得一人]
[愿得一人] 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:16

    I ran in the same issue. It seems jquery stores the text in an attribute called "text" in the button itself, and not as text inside the button.

    I solved it like this:

        $dialog.dialog({
            resizable:false,
            draggable:false,
            modal:true,
            open:function (event, ui) {
                $(this).parents('.ui-dialog').find('.cancel.ui-button').text('Cancel');
                //or you could use: $(this).parents('.ui-dialog').find('button[text="Cancel"]').text('Cancel');
                $(this).parents('.ui-dialog').find('.add.ui-button').text('OK');
            },
            buttons:[
                {
                    text:"OK",
                    click:function () {
    
                    },
                    "class":"add"
                },
                {
                    text:"Cancel",
                    click:function () {
    
                    },
                    "class":"cancel"
                }
            ]
        });
    

提交回复
热议问题