0

这是一些由 asp.net 为浏览器生成的 Html + jQuery ui 对话框代码..

在我看来,它看起来不错,但问题是,确认按钮会触发具有指定类的链接的单击事件,尽管该事件没有被触发。

[更新:我更改了“$(".lDel_23").click();” 到 document.location.href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ListView_Sections$ctrl1$LinkBut​​ton_Delete','')" 并调用了函数..所以问题似乎是点击触发器无法正常工作链接的href设置为javascript方法..虽然尝试手动点击有效,但jQuery点击触发器调用不起作用..这有什么意义????]

    <a href="#" id="aDel_23"></a>
    <a id="ctl00_ContentPlaceHolder1_ListView_Sections_ctrl1_LinkButton_Delete" title="Delete" class="lDel_23" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ListView_Sections$ctrl1$LinkButton_Delete','')"></a>
     <div id="dialog_23" title="Confirm Delete">
           Delete Section [section name]
     </div>

     <script type="text/javascript">
            $(document).ready(function() {
                $("#dialog_23").dialog({
                    autoOpen: false,
                    modal: true,
                    width: 400
                });
                // Link to open the dialog
                $("#aDel_23").click(function(event) {
                    event.preventDefault();
                    $("#dialog_23").dialog({
                        buttons: {
                            'Confirm': function() {
                                $(this).dialog('close');
                                $(".lDel_23").click();
                            },
                            'Cancel': function() {
                                $(this).dialog('close');
                            }
                        }
                    });

                    $('#dialog_23').dialog("open");
                });
            });
    </script>
4

1 回答 1

2

Apparently it is a bit more fiddly to trigger a link on an "a" tag. See if this questions helps out: trigger a click on a anchor link

Basically change this: $(".lDel_23").click(); to $(".lDel_23").get(0).click();

于 2012-10-23T13:34:33.217 回答