如何显示带有“确定”按钮的jQuery对话框?

4
下面是我的代码:
$("#success").dialog({
    modal: true,
    title: 'Payment success',
    width: 400,
});

如何在此对话框中显示“确定”按钮?

我认为你应该在其他属性中再添加另一个键 buttons: {"ok": function() {}} - mohkhan
3
您所需的一切都在 API 文档中:http://api.jqueryui.com/dialog/#option-buttons - Rory McCrossan
@RoryMcCrossan 干得好,但为什么不把这个发布为答案?^^ - Mingebag
3个回答

17

使用 Buttons 选项 并查看 模态消息

$("#success").dialog({
  modal:true,
  title:'Payment success',
  width:400,
  buttons: {
    Ok: function() {
      $( this ).dialog( "close" );
    }
  }
});

2
$("#success").dialog({modal:true,title:'Payment success',width:400,buttons{"Ok":execute,"Cancel": cancel}});

var execute = function()
{
    alert('This is Ok button');
}

var cancel = function()
{
    alert('This is Cancel button');
}

那应该可以工作。


1
$("#success").dialog({
modal:true,
title:'Payment success',
width:400,
buttons: {
        Ok: function() {
            $(this).dialog('close');
        }
});

这应该会添加一个带有“确定”文本的按钮,当你点击按钮时,对话框将关闭 :)

http://jqueryui.com/dialog/


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接