Happy.js icon indicating copy to clipboard operation
Happy.js copied to clipboard

need to add async validation

Open diversario opened this issue 11 years ago • 1 comments

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?

diversario avatar May 02 '14 22:05 diversario

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).

wraithgar avatar May 03 '14 00:05 wraithgar