【问题标题】:Allow button to be clicked once JavaScript允许按钮被点击一次 JavaScript
【发布时间】:2018-04-27 11:10:14
【问题描述】:

我的网站上有一些模式。目前,当您单击确认时,它会发送多个确认。

重新发送部分邀请:

<div id="resendInvitePopup" class="popup-basic admin-form mfp-with-anim modalPopup">
<div class="panel">
    <div class="panel-heading">
        <span class="panel-title">
            <i class="fa fa-check"></i>Confirm
        </span>
    </div>
    @* end .panel-heading section *@

    <div class="panel-body p25">
        <div class="section row">
            <div class="col-md-12 text-center">
                <h3>Are you sure you want to <b class="text-success">re-send</b> this invite?</h3>
                <p class="popupInfo fs12">An invite email will be sent to the user on confirmation</p>

                <div class="summaryBox popupSummary formContainer">
                    @Html.Partial("_ResendInviteForm", Model)
                </div>

                </div>
            @* end section *@
        </div>
        @* end section row section *@

    </div>
    @* end .form-body section *@

    <div class="panel-footer">
        <div class="text-center">
            <input type="button" class="btn btn-primary CancelForm" value="Cancel" />
            <input type="submit" class="btn btn-success SubmitForm" value="Send" />
        </div>
    </div>
    @* end .form-footer section *@
</div>
@* end: .panel *@
<button title="Close (Esc)" type="button" class="mfp-close">×</button>

由于我的代码太大,我已链接到 Fiddle:https://dotnetfiddle.net/9tAmio

【问题讨论】:

  • 你能试试 e.preventDefault();

标签: javascript c# jquery ajax asp.net-mvc-5


【解决方案1】:

您可以使用 jQuery 函数one 确保事件只触发一次。

$('.ConfirmSubmit').one('click', function (e) {
    // Submit form when the user confirms via the modal
    $("#SubmitForm").trigger('click');

});

【讨论】:

  • 但是你的&lt;form&gt;标签在哪里,我在你的问题中看不到任何标签。
猜你喜欢
  • 1970-01-01
  • 2020-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-21
  • 2020-05-16
  • 1970-01-01
相关资源
最近更新 更多