PWV-1: Fixing form dialogs confirm action

This commit is contained in:
Bruno Alves de Faria 2016-10-04 09:27:28 -03:00 committed by Erik Ziegler
parent 107a6538a7
commit 48002420ca

View File

@ -1,11 +1,9 @@
import { Template } from 'meteor/templating'; import { Template } from 'meteor/templating';
import { _ } from 'meteor/underscore'; import { _ } from 'meteor/underscore';
Template.dialogForm.onRendered(() => { Template.dialogForm.onCreated(() => {
const instance = Template.instance(); const instance = Template.instance();
const $modal = instance.$('.modal');
instance.api = { instance.api = {
confirm() { confirm() {
@ -16,7 +14,7 @@ Template.dialogForm.onRendered(() => {
} }
// Hide the modal, removing the backdrop // Hide the modal, removing the backdrop
$modal.modal('hide'); instance.$('.modal').modal('hide');
// Get the form value and call the confirm callback or resolve the promise // Get the form value and call the confirm callback or resolve the promise
const formData = form.value(); const formData = form.value();
@ -29,7 +27,7 @@ Template.dialogForm.onRendered(() => {
cancel() { cancel() {
// Hide the modal, removing the backdrop // Hide the modal, removing the backdrop
$modal.modal('hide'); instance.$('.modal').modal('hide');
// Call the cancel callback or resolve the promise // Call the cancel callback or resolve the promise
if (_.isFunction(instance.data.cancelCallback)) { if (_.isFunction(instance.data.cancelCallback)) {
@ -51,4 +49,9 @@ Template.dialogForm.onRendered(() => {
backdrop: 'static', backdrop: 'static',
keyboard: false keyboard: false
}); });
// Remove the created modal backdrop from DOM after promise is done
const $backdrop = $modal.next('.modal-backdrop');
const dismissDialogBackdrop = () => $backdrop.remove();
instance.data.promise.then(dismissDialogBackdrop, dismissDialogBackdrop);
}); });