【问题标题】:JQUERY using one Dialog open form with corresponding buttonJQUERY 使用一个带有相应按钮的对话框打开表单
【发布时间】:2015-09-29 22:30:10
【问题描述】:

我希望你们都可以帮助我/给我一个正确的方向。 情况如下。我有几个表单,点击时应该弹出(inpage)。为了实现这一点,我正在使用 JQUERY 的 Dialog 功能,它运行良好。唯一的问题是我的页面开始包含大量代码,因为我为每个表单提供了自己的对话框。有没有办法结合使用1对话框的功能? (所以把所有东西都放在一个函数中? - 或者根据按下哪个按钮将表单加载到对话框中?我在网上做了很多搜索,但我找不到任何可以让我朝着正确方向推动的东西...... .希望你们愿意并且能够帮助我。无论如何提前谢谢。(我只展示了前两个功能......我还有大约 6 个)

<script>
    $(function(c) {
        $( "#dialog" ).dialog({
            autoOpen: false,
            maxWidth:260,
            maxHeight: 85,
            width: 260,
            height: 85,
            show: {
                effect: "blind",
                duration: 1000
            },
            hide: {
                effect: "explode",
                duration: 1000
            }
        });

        $( "#dialog" ).dialog({
            position: { 
                my: 'left, top',
                at: 'right, top',
                of: $('#opener')
            }
        });
        $( "#opener" ).click(function() {
            $( "#dialog" ).dialog( "open" );
        });
    });

    $(function(s) {
        $( "#dialog2" ).dialog({
            autoOpen: false,
            maxWidth:300,
            maxHeight: 85,
            width: 300,
            height: 85,
            show: {
                effect: "blind",
                duration: 1000
            },
            hide: {
                effect: "explode",
                duration: 1000
            }
        });

       $( "#dialog2" ).dialog({
           position: { 
               my: 'left, top',
               at: 'right, top',
               of: $('#opener2')
           }
       });

       $( "#opener2" ).click(function() {
           $( "#dialog2" ).dialog( "open" );
       });
 </script>
 <body>
  <?php
    if(!empty($row['voornaam'])){
            ?>
            <div  id="dialog" >Naam<br>
                <p><form method="post"  id="naam"> <input type="text" value="<?php echo $row['voornaam'];?>" name="voornaam"  size="8"/> <input type="text" value="<?php echo $row['achternaam'];?>" name="achternaam"  size="8"/>&nbsp;<input type="submit" value="opslaan" > </form> 
            </div>
        <button id="opener" border="0" color="white"> <?php echo $row['voornaam'] . " " . $row['achternaam']  ;?> &nbsp; <img src="edit.png" width="10" height="10"></button>

        <?php
        } ?>
<?php
    if(!empty($row['gebooredatum'])){
        ?><div id="dialog2" >Geboortedatum<br>
        <p><form method="post" id="leeftijd" > <input type="text" value="" name="geboortedatum" placeholder="<?php echo $row['gebooredatum'];?>" size="11"/> &nbsp;<input type="submit" value="opslaan" > </form> 
        </div>
        <button id="opener2" border="0" color="white"> <?php echo $leeftijd   ;?>&nbsp; Jaar &nbsp; <img src="edit.png" width="10" height="10"></button>


        <?php
    } else {?>
<div  id="dialog2">Geboortedatum<br>
  <p><form method="post" id="leeftijd"> <input type="text" name="geboortedatum" placeholder="dd-mm-jjjj" size="11"/>  <input type="submit" value="opslaan" "size="3"></form></p>
</div>
<button id="opener2" border="0" color="white"><?php echo "Voeg je geboortedatum toe";?> &nbsp;<img src="edit.png" width="10" height="10"></button>
    <?php } ?>

</body>
</html>

【问题讨论】:

    标签: javascript jquery dialog


    【解决方案1】:

    您可以使用 jquery 小部件提供的 open 事件。在此事件中,您可以放置​​一些逻辑来确定您希望在对话框中显示的内容。

    http://api.jqueryui.com/dialog/#event-open

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-26
      • 1970-01-01
      • 2011-05-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多