Skip to content

Commit

Permalink
add domain link: Prevent double add and fix modal operation.
Browse files Browse the repository at this point in the history
Partial #775
  • Loading branch information
makyen committed Aug 19, 2022
1 parent 059981c commit 7a13cf8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 3 additions & 7 deletions app/javascript/domain_links.js
@@ -1,8 +1,4 @@
import { onLoad } from './util';

onLoad(() => {
$('.domain-link-form').on('ajax:success', (ev, data) => {
$('.domain-links-list').append(data);
$(ev.target).parents('.modal').modal('close');
});
$(document).on('ajax:success', '#new_domain_link', (ev, data) => {
$('.domain-links-list').append(data);
$(ev.target).parents('.modal').modal('hide');
});
4 changes: 3 additions & 1 deletion app/javascript/packs/application.js
Expand Up @@ -118,7 +118,9 @@ const metasmoke = window.metasmoke = {
initFormParamCleanups: () => {
const formParameterCleanups = [];

$(document.body).on('submit', 'form', ev => {
// This excludes data-remote, because other JavaScript creates the POST, so this code
// results in a duplicated POST being sent.
$(document.body).on('submit', 'form:not([data-remote="true"])', ev => {
const tgt = $(ev.target);
if (formParameterCleanups.indexOf(tgt[0]) === -1) {
ev.preventDefault();
Expand Down

0 comments on commit 7a13cf8

Please sign in to comment.