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

asynchronous validationValue #81

Open
vanhumbeecka opened this issue Oct 4, 2015 · 1 comment
Open

asynchronous validationValue #81

vanhumbeecka opened this issue Oct 4, 2015 · 1 comment

Comments

@vanhumbeecka
Copy link

Question.

For example: what if you want to check username availability, can you make an asynchronous call to the server to check the availability inside the 'validationValue' element?

The code below doesn't work because Meteor.call is asynchronous. What is best practice here?

ReactiveForms.createElement({
    template: 'UserNameInput',
    validationEvent: 'keyup',
    validationValue: function(el, clean, template) {
        var v = $(el).val();
        console.log(v);
        Meteor.call('isUsernameAvailable', v, function(err, result) {
            if (err) {
                Meteor.Error('could not check username availability.');
            }
            return result;
        });
    }
});
@jonjamz
Copy link
Owner

jonjamz commented Oct 10, 2015

This example might help:

https://github.com/meteortemplates/forms/blob/release/2.0.0/docs/reference/examples/form-elements/advanced/FileUploader.md

Basically you have to return this.stop and then call this.validate(/* value */).

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

No branches or pull requests

2 participants