Question

Here is some Html + jQuery ui dialog code genereated by asp.net for the browser ..

to my eyes it looks fine but the issue is, confirm button triggers click event for the link with the class specified, although the event does not get triggered.

[Update: I changed the "$(".lDel_23").click();" to document.location.href= "javascript:__doPostBack('ctl00$ContentPlaceHolder1$ListView_Sections$ctrl1$LinkButton_Delete','')" and it called the function .. so the problem seems to be the click trigger not able to work correctly with the href of the link set to a javascript method .. although trying the manual click works the jQuery click trigger calling doesnt .. does that make any sense ???? ]

    <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>
Was it helpful?

Solution

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();

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top