invite user: Fix click handler called multiple time on submit.

This commit fixes multiple invite-user-email sent to user.

In invite-user-form, submit-form click handler is getting
called multiple times on submit-invite-user-form event, which
results in multiple invitation mail to user.
Because, we registered same submit click handler multiple times.
Submit form click handler is registered when user opens invite-user
modal. If user opens modal multiple times, click handler get
registered multiple times.

We should register this click handler on `exports.initialize`
function instead of `exports.launch` function. This modal is unlike
other modal, where we append html when user opens modal. In this
case, we append modal on initialization. We only show modal when
user opens. So on initialization, modal element already exists,
register click handler on submit-btn element, on intialization
not when user open modal.

Fixes #10354.
This commit is contained in:
Yashashvi Dave
2018-08-20 23:55:59 +05:30
committed by Tim Abbott
parent f4067bb38b
commit d72280f1c7

View File

@@ -148,7 +148,6 @@ exports.launch = function () {
hashchange.exit_overlay();
},
});
$("#submit-invitation").on("click", submit_invitation_form);
};
exports.initialize = function () {
@@ -161,6 +160,7 @@ exports.initialize = function () {
$('#streams_to_add :checkbox').prop('checked', false);
e.preventDefault();
});
$("#submit-invitation").on("click", submit_invitation_form);
};
return exports;