Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Remove usage of deprecated jqXHR.error in jQuery code #21919

Merged
merged 1 commit into from
Nov 27, 2021

Conversation

braders
Copy link
Contributor

@braders braders commented Oct 23, 2021

Overview

jqXHR.error is deprecated in jQuery 1.8 and removed in jQuery 3.

This update replaces usage of jqXHR.error with the correct jqXHR.fail. (jqXHR refers to the promise interface returned by calls to $.ajax() and $.post())

Before

CiviCRM was using deprecated jQuery methods, which have been removed from jQuery 3.

After

CiviCRM is no longer using the deprecated jqXHR.error method.

Comments

See https://api.jquery.com/jQuery.ajax/#jqXHR for details of the deprecation. CiviCRM appears to currently be using jQuery 1.12.4 which will support the jqXHR.fail method.

Although CiviCRM does not use the host CMS's version of jQuery by default, extensions like https://civicrm.org/extensions/civi-jquery do allow CiviCRM to work in this way. This change will help avoid problems if sites attempt to run CiviCRM with their host CMS' version of jQuery and the host CMS is using jQuery 3.

Longer-term this will be a step towards making it feasable for CiviCRM to upgrade to jQuery 3.

This update replaces usage of jqXHR.error with the correct jqXHR.fail
@civibot
Copy link

civibot bot commented Oct 23, 2021

(Standard links)

@civibot civibot bot added the master label Oct 23, 2021
@braders braders changed the title Remove usage of deprecated jqXHR.error in jQuery code [REF] Remove usage of deprecated jqXHR.error in jQuery code Oct 23, 2021
@colemanw
Copy link
Member

Thanks @braders - the code change looks good to me. Can you give steps for how one would manually test test this on a demo site or local build?

@braders
Copy link
Contributor Author

braders commented Oct 23, 2021

Thanks @braders - the code change looks good to me. Can you give steps for how one would manually test test this on a demo site or local build?

Good question. The easist way to trigger the .fail callback to run is to disconnect network connectivity when the AJAX request is done. You can do this by emulating offline mode from the network tab of your browser's devtools (assuming a Chromium-based or Firefox browser). Alternatively turn off wifi and/or pull out your computers internet cable!

To trigger the API call in templates/CRM/Financial/Form/Search.tpl, go to the "Accounting Batches" (civicrm/financial/financialbatches) page, select a batch and from the " - actions - " dropdown either close or re-open the batch. The AJAX call runs when you click "ok" on the confirmation modal.

For templates/CRM/Financial/Page/BatchTransaction.tpl, click through from "Accounting Batches" to a single batch entry (civicrm/batchtransaction). From here select "Close batch" from near the top of the page. As above the AJAX request is made when you click "ok" in the confirmation dialog. (I assume this will need the batch to be open in order to see the "Close batch" button).

@colemanw
Copy link
Member

Thanks again @braders - this is good to merge.

@colemanw colemanw merged commit 6c58bc7 into civicrm:master Nov 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants