【问题标题】:Jquery dialog add buttons on openJquery对话框在打开时添加按钮
【发布时间】:2013-05-03 08:03:18
【问题描述】:

我有一个 jquery 对话框,其中 autoOpen 设置为 false:

$(document).ready(function() {
$('#test').text("hello!").dialog({
          autoOpen: false,
          resizable: false,
          modal: true,
   });
});

我这样触发对话框:

$('x').click(function() {$('#test').dialog('open');});

我想在打开时添加一些具有某些功能的按钮,如下所示:

$('x').click(function() {$('#test').dialog('open', 'option', 'buttons', {
    'Ok': function() {
        myFunction();
        $(this).dialog('close');
    }
});
});

但到目前为止没有运气,有什么帮助吗?

【问题讨论】:

    标签: javascript jquery jquery-ui


    【解决方案1】:

    把第三部分改成:

    open: function (type, data) {
        $(this).parent().appendTo("form");
    },
    
    buttons: { "Ok": function() { $(this).dialog("close"); } } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多