开发者

How to change button labels in jQuery UI confirmation dialog box

I would like to use jQuery's UI dialog box for confirmation:

$( "#开发者_如何学编程dialog-confirm" ).dialog({
        buttons: {
            "Button One": function() {
                $( this ).dialog( "close" );
            },
            "Button Two": function() {
                $( this ).dialog( "close" );
            }
        }
    });
});

But I would like to change the button labels based on condition:

if (status == "active") {
    var b1 = "Red";
    var b2 = "Green";
} else {
    var b1 = "Green";
    var b2 = "Red";
}

Can't seem to be able to combine the two...


You can set the buttons after the jQuery UI Dialog after it has been created, by supplying a new buttons array.

If you change the status variable to anything apart from active in this demo you can see the buttons get created with different labels.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜