From 54a90353f8ba63a72e8f48e70f675668290b96ef Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 28 Oct 2024 00:28:59 -0700 Subject: [PATCH] Add event listener to chkfallback, enable/disable static IP fields --- app/js/custom.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/js/custom.js b/app/js/custom.js index f6e24558..e893ac20 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -242,16 +242,13 @@ function loadInterfaceDHCPSelect() { $('#txtmetric').val(jsonData.Metric); if (jsonData.StaticIP !== null && jsonData.StaticIP !== '' && !jsonData.FallbackEnabled) { - $('#chkstatic').closest('.btn').button('toggle'); - $('#chkstatic').closest('.btn').button('toggle').blur(); - $('#chkstatic').blur(); + $('#chkstatic').prop('checked', true).closest('.btn').addClass('active'); + $('#chkdhcp').prop('checked', false).closest('.btn').removeClass('active'); $('#chkfallback').prop('disabled', true); $('#dhcp-iface').removeAttr('disabled'); } else { - $('#chkdhcp').closest('.btn').button('toggle'); - $('#chkdhcp').closest('.btn').button('toggle').blur(); - $('#chkdhcp').blur(); - $('#chkfallback').prop('disabled', false); + $('#chkdhcp').closest('.btn').addClass('active'); + $('#chkdhcp').closest('.btn').button.blur(); } if (jsonData.FallbackEnabled || $('#chkdhcp').is(':checked')) { $('#dhcp-iface').prop('disabled', true); @@ -272,6 +269,14 @@ function setDHCPToggles(state) { $('#dhcp-iface').prop('disabled', !state); } +$('#chkfallback').change(function() { + if ($('#chkfallback').is(':checked')) { + setStaticFieldsEnabled(); + } else { + setStaticFieldsDisabled(); + } +}); + $('#debugModal').on('shown.bs.modal', function (e) { var csrfToken = $('meta[name=csrf_token]').attr('content'); $.post('ajax/system/sys_debug.php',{'csrf_token': csrfToken},function(data){