-1

我正在使用 UI 对话框,是否有样式或名称或任何我可以给取消按钮以使其默认关闭对话框的内容?这是我当前的按钮

        <input type="button" value="Cancel" name="close" id="btncancel" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" />

谢谢

编辑:这是我当前的对话框代码和尝试的事件

$(".editDialog").on("click", function (e) {
        var url = $(this).attr('href');
        $("#dialog-edit").dialog({
            title: 'Edit',
            autoOpen: false,
            resizable: true,
            autoResize:true,
            minHeight: 'auto',
            width: width,
            modal: true,
            draggable: true,
            open: function (event, ui) {
                //Show the loading div on open.
                $("#dvLoading").show();
                //adding a callback function wich will be launched after the loading
                $(this).load(url,function(response, status, xhr) {
                    if (status == "error") {
                        var msg = "Sorry but there was an error: ";
                        $(this).html(msg + xhr.status + " " + xhr.statusText);
                    } else $("#dvLoading").hide();
                });
            },
            close: function (event, ui) {
                $(this).dialog('close');
            },
            buttons: {
                "Cancel": function () {
                    $(this).dialog("close");
                }
            }
        });

        $("#dialog-edit").dialog('open');
        return false;
    });
4

2 回答 2

0

参见 对话框示例

<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>jQuery UI Dialog - Modal confirmation</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <script>
  $(function() {
    $( "#dialog-confirm" ).dialog({
      resizable: false,
      height:140,
      modal: true,
      buttons: { // here you can make your button remove ok button then only cancel button come
        "Delete all items": function() {
          $( this ).dialog( "close" );
        },
        Cancel: function() {
          $( this ).dialog( "close" );
        }
      }
    });
  });
  </script>
</head>
<body>

<div id="dialog-confirm" title="Empty the recycle bin?">
  <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>

<p>Sed vel diam id libero <a href="http://example.com">rutrum convallis</a>. Donec aliquet leo vel magna. Phasellus rhoncus faucibus ante. Etiam bibendum, enim faucibus aliquet rhoncus, arcu felis ultricies neque, sit amet auctor elit eros a lectus.</p>


</body>
</html>
于 2013-08-23T14:02:37.293 回答
0

我只是添加了另一个功能,工作正常

function CancelDialog() {
    $("#dialog-edit").dialog().dialog('close');
}
于 2013-08-27T10:27:28.733 回答