Created
September 19, 2018 06:40
-
-
Save samuelmale/bd5dbb554924f20536eb219f87c8dd16 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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. |
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
@dkayiwa The issue is that we don't have an id referencing the link. Since this link was dynamically generated