I have a Hottowel application and a Durandal modal dialog for creating a new entity. In it's viewmodel I have create and cancel functions, which both call close on success. The problem is that modal doesn't close when I call close from another function. It does close when I call it directly.
The code:
var close = function () {
dialog.close(this);
};
var cancel = function () {
datacontext.cancelChanges();
close();
};
var create = function () {
return datacontext.saveChanges()
.then(close);
};
thischanges depending on how the close function is called. You need to make sure thatthisis your viewmodel; otherwise you will never get it to close. - Brettthisis aWindowobject whosegetDialog()method returns the dialog. Calling close from another function makesthisaWindowobject whosegetDialogmethod returnsundefined... Beats me... Anyway, callingvm.close()resolves the issue. - Sljux