0

我有一个问题Jquery Dialog。我正在使用`GriView。在最后一列中,我有一个打开对话框并询问用户电子邮件地址的按钮。一旦关闭,我正在破坏对话框。再次单击第二行按钮时,将打开已输入电子邮件地址的对话框。关闭后如何刷新该模型对话框。另外,我想在单击按钮时将当前行的数据键传递给对话框。我正在这样使用它

data-id='<%# Eval("CompetitionEntryId") %>'

我可以在 html 中看到数据 ID。但是当我尝试通过获取类似的值来提醒 jquery 中的 id 时

var id = $(this).data("id");
            alert(id);

我看不到身份证。[object][object]是警报中的输出。

ASPX

<div class="entryContents">
      <asp:GridView runat="server" AllowPaging="true" ID="entriesGridView" AutoGenerateColumns="false"
            DataKeyNames="CompetitionEntryId" ShowHeader="False" OnRowDataBound="entriesGridView_RowDataBound"
            CssClass="grid">
            <Columns>
                  <asp:BoundField HeaderText="EntryId" DataField="CompetitionEntryId" Visible="False" />
                  <asp:TemplateField>
                        <ItemTemplate>
                              <div class="entry_image">
                                    <asp:Image ImageUrl="" runat="server" ID="entryImage" AlternateText="Challenge Image"
                                          CssClass="image" />
                              </div>
                        </ItemTemplate>
                  </asp:TemplateField>
                  <asp:TemplateField>
                        <ItemTemplate>
                              <div class="challengeInfo">
                                    <div class="title">
                                          <asp:HyperLink runat="server" ID="challengeTitleText"></asp:HyperLink>
                                    </div>
                                    <div class="authorName">
                                          <asp:HyperLink runat="server" ID="authorName"></asp:HyperLink>
                                    </div>
                                    <div class="desc">
                                          <asp:PlaceHolder runat="server" ID="phDesc"></asp:PlaceHolder>
                                    </div>
                              </div>
                        </ItemTemplate>
                  </asp:TemplateField>
                  <asp:TemplateField>
                        <ItemTemplate>
                              <div class="votingSection">
                                    <asp:LinkButton runat="server" ID="voteNowBtn" CssClass="voteNow" Text="Vote Now"
                                          data-id='<%# Eval("CompetitionEntryId") %>'></asp:LinkButton>
                              </div>
                        </ItemTemplate>
                  </asp:TemplateField>
            </Columns>
      </asp:GridView>
</div>
<div class="vote-model" style="display: none;">
      <div class="header">
            <div class="title">
                  <h1>
                        Thank you for voting..
                  </h1>
            </div>
      </div>
      <div class="content">
            <div class="content-info">
                  Please enter your email address below, so that we can send you more information
                  on ** offers!
            </div>
            <div class="field">
                  <asp:Label runat="server" Text="Email Address:" ID="lblEmail"></asp:Label>
                  <asp:TextBox runat="server" ID="txtEmail"></asp:TextBox>
                  <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="txtEmail"
                        ErrorMessage="*required" CssClass="error required"></asp:RequiredFieldValidator>
                  <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" Display="Static"
                        SetFocusOnError="true" CssClass="error invalid" ControlToValidate="txtEmail"
                        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ErrorMessage="Invalid Email Address Format."
                        EnableViewState="false" Text="Invalid Email Address">*Invalid</asp:RegularExpressionValidator>
            </div>
            <div class="field">
                  <asp:CheckBox runat="server" Text="I would like to receive **** offers." />
            </div>
            <div class="btnSections">
                  <asp:LinkButton runat="server" ID="btnCancel" Text="Cancel" />
                  <asp:LinkButton runat="server" ID="btnOk" Text="Submit" />
            </div>
      </div>
</div>

jQuery

$('.voteNow').on("click", function (e) {
            e.preventDefault();
            var id = $(this).data("id");
            alert(id);
            $('.vote-model').dialog({
                  autoOpen: true,
                  width: 600,
                  height: 350,
                  resizable: false,
                  modal: true,
                  draggable: false
            });
      });

      $('#<%= btnCancel.ClientID %>').on("click", function () {
            $('.vote-model').dialog("destroy");
      });
4

1 回答 1

0

尝试这个:

$('.voteNow').on("click", function (e) {
        e.preventDefault();
        var id = $(this).data("id");
        alert(id);
        $('.vote-model').dialog({
              autoOpen: true,
               close: function (event, ui) {
            this.remove();
              },
              width: 600,
              height: 350,
              resizable: false,
              modal: true,
              draggable: false
        });
  });

  });
于 2013-06-10T11:43:08.763 回答