I've created a custom dialog context using Durandal's dialog plugin. The dialog doesn't use a 'blockout', essentially making it non-modal. This all works fine. The problem I'm facing is that it's possible for the user to leave the view that created the dialog (using Durandal's dialog.show()-method), which leaves the dialog visible in the DOM.
My question is two-fold: to solve my immediate problem, I was wondering if it is possible to get a reference to the dialog I created, so I can close it inside the viewmodel that created the dialog in the first place.
Second, to solve this general problem, I would like to always close any open dialogs when a view is deactivated, without having to explicitly code this for every view. Since I'm new to Durandal, I'm uncertain what would be the best approach to do this.
Any suggestions to solve these issues would be appreciated :)