From 2d6cdae1467f4999c6ae5d636f35026ee1bc71a6 Mon Sep 17 00:00:00 2001 From: manchandavishal Date: Fri, 14 Apr 2023 22:40:46 +0530 Subject: Fix deprecation warning for .removeAttr() This patch updates the code to use the .prop() function instead of .removeAttr() which was causing a deprecation warning. For more info. please refer[1]. [1] https://api.jquery.com/removeAttr/ Change-Id: If9e104530d8ac48ead1d29eecabc6831046bc048 --- horizon/static/horizon/js/horizon.forms.js | 8 ++++---- horizon/static/horizon/js/horizon.lists.js | 2 +- horizon/static/horizon/js/horizon.membership.js | 4 ++-- horizon/static/horizon/js/horizon.modals.js | 6 +++--- horizon/static/horizon/js/horizon.tables.js | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/horizon/static/horizon/js/horizon.forms.js b/horizon/static/horizon/js/horizon.forms.js index 8fff1d0f5..66a0fc167 100644 --- a/horizon/static/horizon/js/horizon.forms.js +++ b/horizon/static/horizon/js/horizon.forms.js @@ -74,7 +74,7 @@ horizon.forms = { if ($option.val() == "subnetpool") { $ipVersion.attr("disabled", "disabled"); } else { - $ipVersion.removeAttr("disabled"); + $ipVersion.prop("disabled", false); } }); }, @@ -198,7 +198,7 @@ horizon.forms.handle_submit = function (el) { // Remove disabled attribute on select fields before submit to get value // included in POST request. $this.find('select[disabled="disabled"]').each(function (i, field) { - $(field).removeAttr("disabled"); + $(field).prop("disabled", false); }); return true; }); @@ -379,7 +379,7 @@ horizon.forms.checkSpinnerValue = function($inputs) { var $up = $parent.find('.spinner-up'); var $down = $parent.find('.spinner-down'); - $parent.find('.themable-spinner-btn').removeAttr('disabled'); + $parent.find('.themable-spinner-btn').prop('disabled', false); if (val <= min) { // Disable if we've hit the min @@ -516,7 +516,7 @@ horizon.addInitFunction(horizon.forms.init = function () { //The required verification should be removed and recorded if ($input.attr('required') === 'required') { $input.data('savedRequired', 'required'); - $input.removeAttr('required'); + $input.prop('required', false); } } else { //If the input is a checkbox no need to replace html for label since it has another structure diff --git a/horizon/static/horizon/js/horizon.lists.js b/horizon/static/horizon/js/horizon.lists.js index 123dfdc30..3782be327 100644 --- a/horizon/static/horizon/js/horizon.lists.js +++ b/horizon/static/horizon/js/horizon.lists.js @@ -25,7 +25,7 @@ horizon.lists = { var active_features = $("#selected_"+type+" > li").map(function () { return $(this).attr("name"); }); - $("#"+type+"ListId input:checkbox").removeAttr('checked'); + $("#"+type+"ListId input:checkbox").prop('checked', false); active_features.each(function (index, value) { $("#"+type+"ListId input:checkbox[value=" + value + "]") .prop('checked', true) diff --git a/horizon/static/horizon/js/horizon.membership.js b/horizon/static/horizon/js/horizon.membership.js index 7d453c556..4789cc3ee 100644 --- a/horizon/static/horizon/js/horizon.membership.js +++ b/horizon/static/horizon/js/horizon.membership.js @@ -318,7 +318,7 @@ horizon.membership = { } else { $('#no_' + filter).hide(); - $("input[id='" + filter + "']").removeAttr('disabled'); + $("input[id='" + filter + "']").prop('disabled', false); } }); }, @@ -446,7 +446,7 @@ horizon.membership = { }, 'testQuery': function (query, txt, span) { if ($(input).attr('id') === filter) { - $(input).prev().removeAttr('disabled'); + $(input).prev().prop('disabled', false); return query.test($(span).text()); } else { return true; diff --git a/horizon/static/horizon/js/horizon.modals.js b/horizon/static/horizon/js/horizon.modals.js index b31a9bbf9..f8fff01fd 100644 --- a/horizon/static/horizon/js/horizon.modals.js +++ b/horizon/static/horizon/js/horizon.modals.js @@ -121,7 +121,7 @@ horizon.modals.init_wizard = function () { }); // Temporarilly remove "disabled" attribute to get the values serialized - var disabled = $form.find('select[disabled="disabled"]').removeAttr("disabled"); + var disabled = $form.find('select[disabled="disabled"]').prop("disabled", false); // Send the data for validation. $.ajax({ @@ -321,7 +321,7 @@ horizon.addInitFunction(horizon.modals.init = function() { add_to_field_header = jqXHR.getResponseHeader("X-Horizon-Add-To-Field"), json_data, field_to_update; if (redirect_header === null) { - $('.ajax-modal, .dropdown-toggle').removeAttr("disabled"); + $('.ajax-modal, .dropdown-toggle').prop("disabled", false); } content_disposition = jqXHR.getResponseHeader("content-disposition"); @@ -361,7 +361,7 @@ horizon.addInitFunction(horizon.modals.init = function() { if (jqXHR.getResponseHeader('logout')) { location.href = jqXHR.getResponseHeader("X-Horizon-Location"); } else { - $('.ajax-modal, .dropdown-toggle').removeAttr("disabled"); + $('.ajax-modal, .dropdown-toggle').prop("disabled", false); $formElement.closest(".modal").modal("hide"); horizon.toast.add("danger", gettext("There was an error submitting the form. Please try again.")); } diff --git a/horizon/static/horizon/js/horizon.tables.js b/horizon/static/horizon/js/horizon.tables.js index 878371642..7b8d99632 100644 --- a/horizon/static/horizon/js/horizon.tables.js +++ b/horizon/static/horizon/js/horizon.tables.js @@ -609,7 +609,7 @@ horizon.datatables.update_header_checkbox = function(table) { $multi_select_checkbox.prop('checked', false); $multi_select_checkbox.attr('disabled', true); } else { - $multi_select_checkbox.removeAttr('disabled'); + $multi_select_checkbox.prop('disabled', false); var not_checked = $checkboxes.not(':checked').length; $multi_select_checkbox.prop('checked', not_checked == 0); } -- cgit v1.2.1