How to close a Confirmation Dialog?

Hi guys !

I’d like to develop a way to edit the ‘encounter date’ when an Encounter is created for a past visit. I was thinking of a popup dialog, such as the one suggested in the style guide (used throughout the application)

Something like this:

Q1: Is there a documentation article on how to use/create dialogs ?

I think I understood how to create it using emr.setupConfirmationDialog() JS function.

that way:

var editEncounterDateDialog = null;
function showEditEncounterDateDialog() {
	if (!editEncounterDateDialog) {
		editEncounterDateDialog = emr.setupConfirmationDialog({
			selector: '#encounter-date-dialog',
			actions: {
				confirm: function() {
					//console.log("confirmed");
					$("#encounter-date-dialog").hide();
					$().toastmessage( 'showToast', { type: 'success',
                    		                    position: 'top-right',
                            	                text:  successMessage } );
					return true;
				}
			}
		});
	}
	editEncounterDateDialog.show();
}

But I face one problem: how to close my popup window ?

The $("#encounter-date-dialog").hide(); doesn’t focus well after popup is hidden (user has to click on a section on the left to be able enter obs again).

Looking at the emr.setupConfirmationDialog() function, it looks like there is things available to close my dialog box:

or

But don’t really know how to use that.

Q2: How to close a dialog widget ?

@mksrom by the way, more recently I have come to prefer using this dialog approach: https://wiki.openmrs.org/x/GABXB (this assumes you are writing angular code though).

Peeking at emr.setupConfirmationDialog code, I see that the object it returns has a close() function (see https://github.com/openmrs/openmrs-module-uicommons/blob/master/omod/src/main/webapp/resources/scripts/emr.js#L295 ) and this is what you should be calling instead of {jqselector}.hide()…

If that doesn’t automatically focus the right field, then you’ll need to add a code snippet to do this…

@darius, I am using the widget in an HtmlFormEntry form.

The first option works perfect. Thanks.