0

Basically I have a JQuery UI Dialog but I would need to integrate a checkbox and a submit button in it. Upon clicking the submit button to close the dialog, I would require the checkbox to be checked. It's the same concept as Terms&Condition.

Would anyone mind to share on how to do it/best approach? Been searching around but found nothing close.

Thanks.

<script type="text/javascript">
$(function() {
$("#dialog").dialog({
      autoOpen: true,
      closeOnEscape: false,
      resizable: false,
      draggable: false,
      height: 700,
      width: 700,
      modal: true,
      show: { effect: "fade", duration: 1000 }
      });
  });
  $(function() {
      $("#dialog").dialog({
          buttons: {
          Confirm: function() {
                  $(this).dialog("close");
              }
          }
      });
  });

<asp:CheckBox ID="CheckBox1" runat="server" />
  <asp:Button ID="Button2" runat="server" Text="Button" />
4

1 回答 1

1

You can initially disable the submit button and then toggle whether it is enabled whenever the checkbox is checked:

$('#Button2').attr('disabled', true);

$("#dialog #CheckBox1").change(function() {
  $('#Button2').attr('disabled',!this.checked);
});

Also, I'm not very familiar with jQuery dialog's ability to insert buttons for you because all of the HTML I work with is pre-created by our designers and uses custom binding frameworks, but it looks like you are likewise using pre-generated asp.net HTML. If, so I don't think you would use the jQuery dialog to generate the buttons. Instead you would have code like:

$('#Button2').click(function() {
  // Submit code.  Possibly $.post() and $("#dialog").dialog('close')
  // or triggering the webform's postback.
});
于 2013-03-30T17:08:20.693 回答