mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
settings: Avoid duplicate form handlers.
For forms that are built early in setting up the settings panel, we don't want to attach multiple submit handlers every time we go into the gear menu, so we use "off" to clear any old handlers. We also attach handlers directly to the form, instead of using delegation up to the container div.
This commit is contained in:
@@ -438,7 +438,6 @@ function test_extract_property_name() {
|
||||
$('.signup-notifications-stream-disable').click = set_callback('disable_signup_notifications_stream');
|
||||
|
||||
var submit_settings_form;
|
||||
var submit_profile_form;
|
||||
$('.organization').on = function (action, selector, f) {
|
||||
if (selector === '.subsection-header .subsection-changes-save button') {
|
||||
assert.equal(action, 'click');
|
||||
@@ -447,10 +446,12 @@ function test_extract_property_name() {
|
||||
if (selector === 'button.save-language-org-settings') {
|
||||
assert.equal(action, 'click');
|
||||
}
|
||||
if (selector === 'form.org-profile-form') {
|
||||
};
|
||||
|
||||
var submit_profile_form;
|
||||
$('.organization form.org-profile-form').on = function (action, f) {
|
||||
assert.equal(action, 'submit');
|
||||
submit_profile_form = f;
|
||||
}
|
||||
};
|
||||
|
||||
var change_allow_subdomains;
|
||||
|
||||
@@ -301,7 +301,7 @@ var instructions_selector = "#user-groups #1 .save-instructions";
|
||||
test_create_item(create_item_handler);
|
||||
|
||||
// Tests for settings_user_groups.set_up workflow.
|
||||
assert.equal(typeof($('.organization').get_on_handler("submit", "form.admin-user-group-form")), 'function');
|
||||
assert.equal(typeof($('.organization form.admin-user-group-form').get_on_handler("submit")), 'function');
|
||||
assert.equal(typeof($('#user-groups').get_on_handler('click', '.delete')), 'function');
|
||||
assert.equal(typeof($('#user-groups').get_on_handler('keypress', '.user-group h4 > span')), 'function');
|
||||
}());
|
||||
@@ -497,7 +497,7 @@ var instructions_selector = "#user-groups #1 .save-instructions";
|
||||
};
|
||||
|
||||
(function test_admin_user_group_form_submit_triggered() {
|
||||
var handler = $('.organization').get_on_handler("submit", "form.admin-user-group-form");
|
||||
var handler = $('.organization form.admin-user-group-form').get_on_handler("submit");
|
||||
var event = {
|
||||
stopPropagation: noop,
|
||||
preventDefault: noop,
|
||||
|
||||
@@ -95,7 +95,7 @@ exports.set_up = function () {
|
||||
|
||||
var emoji_widget = emoji.build_emoji_upload_widget();
|
||||
|
||||
$(".organization").on("submit", "form.admin-emoji-form", function (e) {
|
||||
$(".organization form.admin-emoji-form").off('submit').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var emoji_status = $('#admin-emoji-status');
|
||||
|
||||
@@ -66,7 +66,7 @@ exports.set_up = function () {
|
||||
});
|
||||
});
|
||||
|
||||
$(".organization").on("submit", "form.admin-filter-form", function (e) {
|
||||
$(".organization form.admin-filter-form").off('submit').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var filter_status = $('#admin-filter-status');
|
||||
|
||||
@@ -673,7 +673,7 @@ function _set_up() {
|
||||
}
|
||||
});
|
||||
|
||||
$(".organization").on("submit", "form.org-profile-form", function (e) {
|
||||
$(".organization form.org-profile-form").off('submit').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
@@ -708,7 +708,7 @@ function _set_up() {
|
||||
});
|
||||
});
|
||||
|
||||
$(".organization").on("submit", "form.org-authentications-form", function (e) {
|
||||
$(".organization form.org-authentications-form").off('submit').on('submit', function (e) {
|
||||
var authentication_methods_status = $("#admin-realm-authentication-methods-status").expectOne();
|
||||
|
||||
var new_auth_methods = {};
|
||||
|
||||
@@ -282,7 +282,7 @@ exports.set_up = function () {
|
||||
meta.loaded = true;
|
||||
exports.populate_user_groups();
|
||||
|
||||
$(".organization").on("submit", "form.admin-user-group-form", function (e) {
|
||||
$(".organization form.admin-user-group-form").off("submit").on("submit", function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user