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
This commit is contained in:
manchandavishal 2023-04-14 22:40:46 +05:30
parent 7d44796eca
commit 2d6cdae146
5 changed files with 11 additions and 11 deletions

View File

@ -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

View File

@ -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)

View File

@ -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;

View File

@ -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."));
}

View File

@ -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);
}