Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In the newly-added event subscription, we listen for (FRAGMENT-ID).delete-button-clicked, namely the event we defined in the action. The callback function we register with the subscription counts on being passed the patientIdentifierId (i.e. the "property" on the action) as extra data. We ask the user to confirm their action using the openmrsConfirm function. (Currently this just calls the standard Javascript confirm function, but by using our own OpenMRS method, we'll be able to make the look and feel prettier in the future, by changing code in just one place.) Assuming the users confirms the deletion, we do a standard jQuery post to our new deleteIdentifier action, passing the relevant id as data, and reloading the page on success. (This is a placeholder-: we'll ajaxify shortly.) Finally, we define a function to be called on error. It is good practice to handle errors from every ajax call you make-: displaying anything at all (even something not particularly meaningful to the end user) is better than a silent error.

...