Skip to content

Instantly share code, notes, and snippets.

@samuelmale
Created September 19, 2018 06:40
Show Gist options
  • Save samuelmale/bd5dbb554924f20536eb219f87c8dd16 to your computer and use it in GitHub Desktop.
Save samuelmale/bd5dbb554924f20536eb219f87c8dd16 to your computer and use it in GitHub Desktop.
// We created our link dynamically from here
@Override
public Map<String, String> getLinks() {
Map<String, String> links = new HashMap<String, String>();
if (ModuleUtil.compareVersion(OpenmrsConstants.OPENMRS_VERSION, DIAGNOSIS_MIGRATION_LEAST_SUPPORTED_VERSION) >= 0) {
links.put("module/emrapi/MigrateDiagnosis.form", Context.getMessageSourceService().getMessage("emrapi.migrateDiagnosis.migrateDiagnosisLink.name"));
}
return links;
}
// Looking at our admin page(https://demo.openmrs.org/openmrs/admin/index.htm), the link is dynamically created by
// the above code.
// Now we wanna create an alert box when that link is clicked.
// Lets assume some JS code. We assume it compiles :)
$('#linkId').onClick(function(){
// Just make an alert
alert('Hey you clicked me');
});
// Buts Oooppss, we don't have the id.
@samuelmale
Copy link
Author

Well does this make sense here?
Selecting that element using the href attribute!

$("a[href$='module/emrapi/MigrateDiagnosis.form']")...

cc: @dkayiwa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment