jquery如何获得此对话框确定按钮工作?

时间:2016-04-19 15:43:22

标签: javascript jquery

显示对话框并完美运行。右上角" X"关闭按钮正确关闭对话框,但“确定”按钮不执行任何操作。 (我使用jquery 1.9.1)

([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$env:COMPUTERNAME)).CreateSubKey('SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\RC4 128/128') 

我也尝试过没有逗号后面的按钮:

  function showFollowProjectInDialog(followurl){
      $.ajax({
        url: followurl,
        success: function(data) {
          $("#TFdialog").html(data).dialog({
            resizable: true,
            height: 600,
            width: 700,
            modal:true,
            buttons: {
            Ok: function() {$( "#TFdialog" ).dialog( "close" );}
            },
            }).dialog('open');
        }
      });
    }

我已经尝试过这些:

buttons: {
    Ok: function() {$( "#TFdialog" ).dialog( "close" );}
        }
}).dialog('open');

buttons: [{
            text: "Ok",
            Click : function () {
                $("#TFdialog").dialog("close");
            }
        }]

我已经尝试更换"#TFdialog"用这个'像:

buttons: [{
 Ok: function() {
     $("#TFdialog").dialog("close");
 }
}]

2 个答案:

答案 0 :(得分:2)

尝试做

    buttons: [
    {
        text: "Ok",
        click: function() {
          $( this ).dialog( 'close' );
          // your code goes here
        }
      }
    ]

答案 1 :(得分:0)

假设你使用jQuery UI Reference https://jqueryui.com/dialog/#modal-form

buttons: {
        Ok: function() {
          $( this ).dialog( "close" );
        }
      }

您也可以将对话框用作对象:

var myDialog;
myDialog = $("#TFdialog").html(data).dialog({
            resizable: true,
            autoOpen: false,// added this
            height: 600,
            width: 700,
            modal:true,
            buttons: {
               Ok: function() {
                  myDialog.dialog( "close" );
                  },
              "Close this Soon" : DelayClose,
            }
            });
myDialog.dialog('open');

function DelayClose(){
   setTimeout(function() {
    myDialog.dialog( "close" );
  }, 500 );
}

为什么要使用对象的示例:

var myDialog;
myDialog = $("#TFdialog").dialog({
            resizable: true,
            autoOpen: false,// added this
            height: 600,
            width: 700,
            modal:true,
            buttons: {
               Ok: function() {
                  myDialog.dialog( "close" );
                  }
            }
            });

function showFollowProjectInDialog(followurl){
    $.ajax({
        url: followurl
    }).done(function(data){
        $("#TFdialog").html(data);
        myDialog.dialog('open');
    });
}