一旦JavaScript单击允许按钮

时间:2018-04-27 11:10:15

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

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

重新发送邀请部分:

<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>

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

1 个答案:

答案 0 :(得分:4)

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

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

});