开发者

Issue getting my jquery dialog to open up and show

开发者 https://www.devze.com 2023-03-09 20:28 出处:网络
I have the follow开发者_StackOverflowing javascript function <script type=\"text/javascript\">

I have the follow开发者_StackOverflowing javascript function

 <script type="text/javascript">
   function ShowAlert(id) {
     //  alert('I am here' + id);
       $(id).dialog('open');

   }

var dl;
$(document).ready(function () {
    //setup edit person dialog             
    $('#editPerson').dialog({
        //Setting up the dialog properties.
        show: "blind",
        hide: "fold",
        resizable: false,
        modal: true,
        height: 400,
        width: 700,
        title: "Modify Member"
    });
            $("#<%=ButtonAdd.ClientID %>").click(function () {
                var dl = $("#divDlg").dialog({
                    //Setting up the dialog properties.
                    show: "blind",
                    hide: "fold",
                    resizable: false,
                    modal: true,
                    height: 400,
                    width: 700
                });
               // dl.parent().appendTo(jQuery('form:first'));
            });


    //Adding a event handler for the close button that will close the dialog 
    $("a[id*=ButtonCloseDlg]").click(function (e) {
        $("#divDlg").dialog("close");
        return false;
    });

});

In my gridviews item template for my edit button I have the following to call the function. Which works to show an alert but can't get it to show the dialog? Is it because possibly the postback happening on the grid causing it to close?

   <ItemTemplate>
       <asp:Button ID="ButtonEdit" runat="server" CausesValidation="false" 
            CommandName="EditMember" OnClientClick='ShowAlert("#editPerson");' 
            Text="Edit" />
   </ItemTemplate>

Any help would be greatly appriated.


I'd be very cautious about using

$("#<%=ButtonAdd.ClientID %>").click(...

in client-side javascript code.

A better approach would be to use jQuery's "attribute ends with" selector. Considering that ASP.Net appends your ID from the ASPX page to end of its generated HTML (try viewing the source of the page after it's loaded in the browser), this should get around it - assuming that's the problem..

0

精彩评论

暂无评论...
验证码 换一张
取 消