0

在我的网页上,我有这个链接:

<\a onclick="#" class="compose"></a>

通过单击链接,此脚本被激活:

$(function(){
    $('.compose').click(function() { // Button which will activate our modal
        $('#popup_bestanden_edit_name').reveal({ // The item which will be opened with reveal 
            animation: 'fade',  // fade, fadeAndPop, none
            animationspeed: 600,                // how fast animtions are
            closeonbackgroundclick: true,   // if you click background will modal close?
            dismissmodalclass: 'close'  // the class of a button or element that will close an open modal
        });
        return false;
    });
});

上面的脚本将使这个 DIV 可见,这是一个弹出窗口:

<div id="popup_bestanden_edit_name">
<div id="popupheading">
    Naam wijzigen
</div>

<div id="popupcontent">
    <p><form action="" method="post" name="naamwijzigen"><input name="naam" type="text"></form></p>

    <a href="#" class="popupbutton green close"><img src="<?php echo $domein.'/images/confirm_popup/tick.png'; ?>">Ja, wijzigen</a>

    <a href="#" class="popupbutton red close"><img src="<?php echo $domein.'/images/confirm_popup/cross.png'; ?>">Nee, annuleren</a>
</div>

打开的弹出窗口使人们有机会在网站上编辑文档的名称。所以当点击链接时<\a onclick="#" class="compose"></a>,它必须向$fetch_row['id']弹出窗口发送一个 id ( ),所以我可以在进一步的脚本中使用它。

有谁知道如何做到这一点?

4

4 回答 4

1

像这样将 id 添加到您的标签中

<a onclick="#" class="compose" data-id="<?php echo $fetch_row['id']?>"></a>

然后获取 id 并使用 Jquery 将其发送到您的弹出窗口:

id = $(this).attr("data-id");

现在在任何你想要的地方使用这个 id。

于 2013-09-29T11:59:55.180 回答
0

仅将 id 添加到锚标记,即

<a id = '2' class='compose' ></a>

然后你可以像 jQuery('.compose').attr('id');

于 2013-09-29T12:01:47.710 回答
0

jQuery 显示插件有许多回调函数,其中opened回调函数在模式打开后触发。请参阅foundation.zurb.com 上的文档

echo "<a onclick='#' class='compose' id='".$fetch_row['id']."'></a>";

$(function(){
    $('.compose').click(function() { 

        var id = $(this).attr('id'); //getting id from clicked anchor tag

        $('#popup_bestanden_edit_name').reveal({ 
            animation: 'fade',  
            animationspeed: 600,               
            closeonbackgroundclick: true,   
            dismissmodalclass: 'close',//missing comma (,) added

            opened: function(id) { 
               $("#popup_bestanden_edit_name").append("<input type='hidden' name='myid' id='myid' value='"+id+"'>");
            }

        });
        return false;
    });
});

您的 id 将myid在弹出窗口中的元素中设置,从这里获取。

于 2013-09-29T12:39:51.320 回答
0

现在一切正常我还有一个问题。这是我现在使用的代码:

echo "<a onclick='#' class='compose' id='".$fetch_row['id']."'></a>";

$(function(){
$('.compose').click(function() { 

    var id = $(this).attr('id'); //getting id from clicked anchor tag

    $('#popup_bestanden_edit_name').reveal({ 
        animation: 'fade',  
        animationspeed: 600,               
        closeonbackgroundclick: true,   
        dismissmodalclass: 'close',//missing comma (,) added

        opened: function(id) { 
           $("#popup_bestanden_edit_name").append("<input type='hidden' name='myid' id='myid' value='"+id+"'>");
        }

    });
    return false;
});
});

但是当人们在页面底部时单击链接时,弹出窗口将在页面顶部打开。但是人们需要滚动回顶部才能看到这一点。

如何自动将用户发送回显示弹出窗口的顶部?

于 2013-09-29T22:04:46.563 回答