ui: lazily hook settings-changed trigger in saveFormToEndpoint()

When the storing succeeded we can trigger similar to how the grid does
it in its own private scope.  This should get rid of the two Unbound
spots where this is used and automatically work in other places.
This commit is contained in:
Franco Fichtner 2026-05-12 07:41:10 +02:00
parent 7c8a426bbe
commit 45ef8ddd1a
3 changed files with 7 additions and 9 deletions

View file

@ -31,9 +31,7 @@ $( document ).ready(function() {
$('.selectpicker').selectpicker('refresh');
$("#unbound\\.acls\\.default_action").change(function() {
saveFormToEndpoint(url="/api/unbound/settings/set", formid="frm_AclSettings", function() {
$(document).trigger("settings-changed");
});
saveFormToEndpoint(url="/api/unbound/settings/set", formid='frm_AclSettings');
});
});

View file

@ -38,9 +38,7 @@
});
$(".forwarding-enabled").click(function() {
saveFormToEndpoint(url="/api/unbound/settings/set", formid='frm_ForwardingSettings', function () {
$(document).trigger("settings-changed");
});
saveFormToEndpoint(url="/api/unbound/settings/set", formid='frm_ForwardingSettings');
let checked = ($(this).is(':checked'));
toggleNameservers(checked);

View file

@ -98,15 +98,17 @@ function saveFormToEndpoint(url, formid, callback_ok, disable_dialog, callback_f
});
}
if ( callback_fail !== undefined ) {
if (callback_fail !== undefined) {
// execute callback function
callback_fail(data);
}
} else if ( callback_ok !== undefined ) {
} else if (callback_ok !== undefined) {
// trigger base apply button alert
$(document).trigger('settings-changed');
// execute callback function
callback_ok(data);
}
} else if ( callback_fail !== undefined ) {
} else if (callback_fail !== undefined) {
callback_fail(data);
}
});