代码之家  ›  专栏  ›  技术社区  ›  yogsma

单击按钮时弹出窗体

  •  4
  • yogsma  · 技术社区  · 15 年前

    有没有一种方法可以使用jquery在单击按钮时在弹出窗口中创建表单?窗体将有几个输入字段和“保存”和“取消”按钮。因此,单击“保存”后,表单中的信息将保存在数据库中,并返回到原始屏幕。我想要一个淡入式弹出窗口。

    6 回复  |  直到 9 年前
        1
  •  5
  •   Lorenzo OnoSendai    15 年前

    使用此代码

    HTML

    <div id="divdeps" style="display:none" title=""></div>
    

    关于dom的jquery就绪

    $("#divdeps").dialog({
        autoOpen: false,
        show: 'slide',
        resizable: false,
        position: 'center',
        stack: true,
        height: 'auto',
        width: 'auto',
        modal: true
    });
    

    此代码将初始化一个对话框,并将其置于准备打开和连续关闭的状态。 如果要在页面加载时打开对话框,请在文档中已添加的代码就绪后添加此行代码:

    $("#divdeps").dialog('open');
    

    如果要打开单击事件后面的对话框,请在应触发打开的元素的单击事件上添加相同的代码。

    将您的表单添加到mydialog分区中。如果您需要有关表单提交的更多帮助,请提供更多详细信息…

        3
  •  1
  •   tpow    15 年前

    查找jquery用户界面对话框。

    使用表单创建一个DIV:

    <div id=form>
     your form here
    </div>
    

    然后调用一个对话框实例(Probay链接这是某种单击处理程序来触发窗体)

                           $('#form').dialog({
                                modal: true,
                                buttons:
                              { "Cancel": function() {
                                  $(this).dialog("close")
                              },
                                  "Submit": function() {
                                   //put code here for form submission
                               }
                           });
    
        4
  •  1
  •   David    9 年前

    下面是一个使用jquery的示例。您可以检查其他类型的弹出窗口 Dialog 详细地说。

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>jQuery UI Dialog - Animation</title>
      <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
      <link rel="stylesheet" href="/resources/demos/style.css">
      <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
      <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
      <script>
      $( function() {
        $( "#dialog" ).dialog({
          autoOpen: false,
          show: {
            effect: "blind",
            duration: 1000
          },
          hide: {
            effect: "explode",
            duration: 1000
          }
        });
    
        $( "#opener" ).on( "click", function() {
          $( "#dialog" ).dialog( "open" );
        });
      } );
      </script>
    </head>
    <body>
    
    <div id="dialog" title="Basic dialog">
      <p>This is an animated dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
    </div>
    
    <button id="opener">Open Dialog</button>
    
    
    </body>
    </html>
    
        5
  •  0
  •   casablanca    15 年前

    看看 jQuery UI Dialog . 它完全按照您的需要执行,并且可以配置为添加动画,如淡入。

        6
  •  -1
  •   Salik    12 年前

    我正在使用下面的弹出框,它看起来更吸引人。

    http://gristmill.github.io/jquery-popbox/