Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validating state during async validation #63

Open
steph643 opened this issue Apr 14, 2015 · 4 comments
Open

Add validating state during async validation #63

steph643 opened this issue Apr 14, 2015 · 4 comments
Labels

Comments

@steph643
Copy link

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 #36. However here is a separate issue, in case some other ways will be preferred to support this use case.

@jonjamz
Copy link
Owner

jonjamz commented Apr 14, 2015

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.

@steph643
Copy link
Author

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:

  • I created an element containing a button and validationEvent = 'click'
  • In validationValue(), I call showBootstrapModal() and return this.stop
  • I call this.validate() (if appropriate) in onClose()

(well, in fact I do all this through a modified version of the API described in #36)

@jonjamz
Copy link
Owner

jonjamz commented Apr 18, 2015

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?

@jonjamz jonjamz changed the title Feature request: support for selection in dialog box (= async validation?) Add validating state during async validation Apr 18, 2015
@steph643
Copy link
Author

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 #61). This may or may not be related to SimpleSchema clean function (I need to pass { removeEmptyStrings: false } everywhere, which adds to the complexity).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants