Happy.js
Happy.js copied to clipboard
need to add async validation
Documentation says:
arg (anything):
...or to make a server call to check if a username is available
However, from reading the source it looks like arg function must be synchronous
error = !opts.test(val, arg);
which isn't going to work well for server calls.
Is this correct or is there a way to have arg be async function?
Nope it's totally synchronous. At this time you'd have to use something like $.ajax({async: false}) and a properly scoped return value in your test function, which is obviously pretty janky. Async validation, in a javascript environment, should probably work no? Let's repurpose this issue to try to add async validation (not a quick solution I admint).