【问题标题】:Adding a name to a JQuery Dialog Bottom Button向 JQuery 对话框底部按钮添加名称
【发布时间】:2011-12-09 15:34:32
【问题描述】:

我正在尝试将名称(不是显示的文本)添加到底部面板上的按钮,但找不到方法。

这就是我目前所拥有的......

    $("#dialog-import-from-existing").dialog({
        title: "Import From Existing",
        autoOpen: false,
        modal: true,
        draggable: false,
        resizable: false,
        width: 500,
        height: 525,

            buttons: {
                **name : "SubmitButton",**
                "Import": function() {
                $('#CreateForm').submit();
                $(this).dialog('close');
            },
            "Cancel": function() {
                //Need to added the js files to Driver studio.
                //$("models-to-add-container").effect("explode");
                $(this).dialog('close');
            }
            }
        });

我正在尝试使用名称为“SubmitButton”的此按钮。

提前致谢。

【问题讨论】:

    标签: jquery jquery-ui


    【解决方案1】:

    按钮选项有两个 API。您正在使用将按钮标签映射到单击功能的原始、更简单的 API。您还可以使用对象数组,从而获得更多控制权。

    $( "#dialog-import-from-existing" ).dialog({
        ...
        buttons: [
            {
                name: "SubmitButton",
                text: "Import",
                click: function() {
                    $( "#CreateForm" ).submit();
                    $( this ).dialog( "close" );
                }
            },
            {
                text: "Cancel",
                click: function() {
                    $( this ).dialog( "close" );
                }
            }
       ]
    });
    

    此 API 允许您传递可以传递给 .attr() 以及事件处理程序的任何内容。

    【讨论】:

      【解决方案2】:

      试试:

      $("#dialog-import-from-existing").dialog({
          ...
          open: function() {
              $(this).parent().find('.ui-dialog-buttonpane button:contains("Import")').
                  attr('name', 'SubmitButton');
          }
      });
      

      (来自jQuery UI Dialog Button Icons

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-07
        • 2010-12-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-07-13
        相关资源
        最近更新 更多