【问题标题】:Jquery ui dialog widget add buttonsJquery ui 对话框小部件添加按钮
【发布时间】:2013-06-06 17:27:25
【问题描述】:

我想在对话框中添加新按钮,而不会丢失以前的按钮。 我使用了以下代码,但它不起作用....

 menu.dialog("open");
                var buttons = menu.dialog("option", "buttons");
                //$.extend(buttons, {text: label, click: function(){ alert("Added New Poker Face"); } });
                buttons[label] = function () { alert("Addded New poker Face"); };
                menu.dialog("option", "buttons", buttons);                    

我什至使用过扩展来覆盖按钮列表,上面评论说没有运气 请为此提供任何解决方法

【问题讨论】:

    标签: jquery-ui jquery-ui-dialog


    【解决方案1】:

    doc 表示.dialog("option", "buttons") 的返回值可以是对象{label1: click1, label2: click2, ...} 或数组[{"text": label1, "click": click1}, {"text": label2, "click": click2}, ...]

    您检查过buttons 的格式吗?如果它是一个数组,你应该.push()你的新按钮。

    【讨论】:

    • 返回对象。我使用过扩展功能,但它不起作用
    【解决方案2】:

    我们可以做一些像下面这样对我有用的事情.....

                    //gets the list of buttons.
                    var buttons = menu.dialog("option", "buttons");
                    //Adds the new button to the existing list of buttons.
                    buttons.push({ text: label, click: function () { alert("Addded New poker Face"); } });                
                    //Gives the new list of buttons to the dialog to display.
                    menu.dialog("option", "buttons", buttons);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-05
      • 2019-08-26
      • 2016-05-31
      • 2011-12-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多