I have a service in my application that shows a Bootstrap dialog. The code is very simple at the moment:
async showConfirmation(message: string): Promise<boolean> {
this.message(message);
this.isPopupOpen(true);
return false;
}
At the moment the dialog HTML look like this:
<div role="dialog" aria-hidden="true" class="modal fade" data-bind="modal: { show: isPopupOpen }">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" title="Close" aria-label="Close">×</button>
<h4 class="modal-title">My Modal</h4>
</div>
<div class="modal-body" data-bind="text: message"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" data-bind="click: close">Cancel</button>
<button type="button" class="btn btn-primary" data-dismiss="modal" data-bind="click: close">OK</button>
</div>
</div>
</div>
</div>
The close handler in my view model is also very simple, like this:
close(data, event) {
//console.debug(data);
console.debug(event.target);
this.isPopupOpen(false);
}
At the moment the showConfirmation
function immediately returns a hard coded false
whereas I want to wait for the users response and return that as the result of showConfirmation
.
I'm not entirely sure of the best way to achieve this. How can I make this wait for the user in order to return the appropriate response?