From 6b0aa201798cb0a893d1b9a1bcc1fa465f8b340f Mon Sep 17 00:00:00 2001 From: manchandavishal Date: Tue, 11 Apr 2023 23:26:46 +0530 Subject: [PATCH] Update jQuery click event to remove deprecation warning The shorthand jQuery.fn.click() event has been deprecated in favor of the on() method. This patch updates the code to use the on() method instead to remove the deprecation warning. For more information about the deprecation of jQuery.fn.click(), please refer [1]. [1] https://api.jquery.com/click/ Change-Id: Ic44aaded8d0aaa70e38e46d4121dc3c825f3b831 --- horizon/static/horizon/js/horizon.messages.js | 2 +- .../theme-preview/theme-preview.directive.js | 4 ++-- .../static/js/horizon.flatnetworktopology.js | 14 +++++++------- .../static/js/horizon.networktopology.js | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/horizon/static/horizon/js/horizon.messages.js b/horizon/static/horizon/js/horizon.messages.js index 94d654efe2..049a94273d 100644 --- a/horizon/static/horizon/js/horizon.messages.js +++ b/horizon/static/horizon/js/horizon.messages.js @@ -100,7 +100,7 @@ horizon.addInitFunction(function () { }); // Dismiss alert messages when moving on to a new type of action. - $('a.ajax-modal').click(function() { + $('a.ajax-modal').on('click', function() { horizon.clearAllMessages(); }); diff --git a/openstack_dashboard/contrib/developer/static/dashboard/developer/theme-preview/theme-preview.directive.js b/openstack_dashboard/contrib/developer/static/dashboard/developer/theme-preview/theme-preview.directive.js index f7abf562af..fc67dcc7c1 100644 --- a/openstack_dashboard/contrib/developer/static/dashboard/developer/theme-preview/theme-preview.directive.js +++ b/openstack_dashboard/contrib/developer/static/dashboard/developer/theme-preview/theme-preview.directive.js @@ -43,7 +43,7 @@ function link(scope, element) { //TODO(tqtran) Use angular, not jQuery - $('a[href="#"]').click(function(e) { + $('a[href="#"]').on('click', function(e) { e.preventDefault(); }); @@ -51,7 +51,7 @@ var $pre = $uibModal.find('pre'); var $button = $('
') - .click(function(){ + .on('click', function(){ var $parent = $(this).parent(); var $fragment = stripAngular($parent.clone()); diff --git a/openstack_dashboard/static/js/horizon.flatnetworktopology.js b/openstack_dashboard/static/js/horizon.flatnetworktopology.js index 944b6f4f19..5e9b50f290 100644 --- a/openstack_dashboard/static/js/horizon.flatnetworktopology.js +++ b/openstack_dashboard/static/js/horizon.flatnetworktopology.js @@ -105,12 +105,12 @@ horizon.flat_network_topology = { e.stopImmediatePropagation(); var vnc_window = window.open($(this).attr('href'), vnc_window, 'width=760,height=560'); self.delete_balloon(); - }) - .click(function(){ + }); + $(document).on('click', function(){ self.delete_balloon(); }); - $('.toggle-view > .btn').click(function(){ + $('.toggle-view > .btn').on('click', function(){ self.draw_mode = $(this).data('value'); $('g.network').remove(); horizon.cookies.put('ntp_draw_mode',self.draw_mode); @@ -621,20 +621,20 @@ horizon.flat_network_topology = { 'left': x + 'px' }).show(); - $balloon.find('.delete-device').click(function(){ + $balloon.find('.delete-device').on('click', function(){ var $this = $(this); var delete_modal = horizon.datatables.confirm($this); - delete_modal.find('.btn.btn-danger').click(function () { + delete_modal.find('.btn.btn-danger').on('click', function () { $this.prop('disabled', true); d3.select('#id_' + $this.data('device-id')).classed('loading',true); self.delete_device($this.data('type'),$this.data('device-id')); horizon.modals.spinner.modal('hide'); }); }); - $balloon.find('.delete-port').click(function(){ + $balloon.find('.delete-port').on('click', function(){ var $this = $(this); var delete_modal = horizon.datatables.confirm($this); - delete_modal.find('.btn.btn-danger').click(function () { + delete_modal.find('.btn.btn-danger').on('click', function () { $this.prop('disabled', true); self.delete_port($this.data('router-id'),$this.data('port-id'),$this.data('network-id')); horizon.modals.spinner.modal('hide'); diff --git a/openstack_dashboard/static/js/horizon.networktopology.js b/openstack_dashboard/static/js/horizon.networktopology.js index c94da29538..02cba863d9 100644 --- a/openstack_dashboard/static/js/horizon.networktopology.js +++ b/openstack_dashboard/static/js/horizon.networktopology.js @@ -142,7 +142,7 @@ horizon.network_topology = { self.refresh_labels(); }); - angular.element('#center_topology').click(function() { + angular.element('#center_topology').on('click', function() { this.blur(); // remove btn focus after click self.delete_balloon(); // move visualization to the center and reset scale @@ -1101,19 +1101,19 @@ horizon.network_topology = { }) .addClass('leftPosition'); } - _balloon.find('.delete-device').click(function() { + _balloon.find('.delete-device').on('click', function() { var _this = angular.element(this); var delete_modal = horizon.datatables.confirm(_this); - delete_modal.find('.btn.btn-danger').click(function () { + delete_modal.find('.btn.btn-danger').on('click', function () { _this.prop('disabled', true); d3.select('#id_' + _this.data('device-id')).classed('loading',true); self.delete_device(_this.data('type'),_this.data('device-id')); }); }); - _balloon.find('.delete-port').click(function() { + _balloon.find('.delete-port').on('click', function() { var _this = angular.element(this); var delete_modal = horizon.datatables.confirm(_this); - delete_modal.find('.btn.btn-danger').click(function () { + delete_modal.find('.btn.btn-danger').on('click', function () { _this.prop('disabled', true); self.delete_port(_this.data('router-id'),_this.data('port-id'),_this.data('network-id')); });