Open steph643 opened 9 years ago
Could you show me an example or walk me through your thought process? I know of several ways to do modals; I'm guessing in this case you used a lib that ran a callback? Another way I could think of would be putting the modal container inside the element itself so you could handle the close event manually.
My modal function is as follow (simplified version):
showBootstrapModal = function (template, data, onClose)
It shows a modal based on a Meteor template and its data context. onClose
is called when the dialog is closed.
What I did:
validationEvent
= 'click'validationValue()
, I call showBootstrapModal()
and return this.stop
this.validate()
(if appropriate) in onClose()
(well, in fact I do all this through a modified version of the API described in https://github.com/meteortemplates/forms/issues/36)
This is currently the best way to do anything async.
One thing I will add to support this is what I first described in #36, the {{validating}}
helper.
And I think if a form has validating
state, it shouldn't be able to be submitted. What do you think?
I have to say I cannot achieve async validation the way I want. I will postpone this to a later stage and find another way until then. This is not critical for me.
I don't need a {{validating}}
helper, because I use async validation in a modal. So, when the modal is displayed, the form is not visible anyway.
What is lacking right now is:
Maybe I am also facing an issue regarding content of this
and/or changed
in the submit function when doing async validation (see https://github.com/meteortemplates/forms/issues/61). This may or may not be related to SimpleSchema clean function (I need to pass { removeEmptyStrings: false }
everywhere, which adds to the complexity).
Here is my use case: I created a form element which contains a "Change" button. When clicking this button, a modal dialog pops up, which allows user to choose among values. User choice is validated when user clicks OK to close the dialog.
With the current version of the package, I implemented this using async validation, as described in discussion https://github.com/meteortemplates/forms/issues/36. However here is a separate issue, in case some other ways will be preferred to support this use case.