Similarly to this question and this question I can't figure out how to How to configure a Parsley custom remote using Javascript, when binding an individual field.
e.g. I'm trying (simplified):
$('#field').parsley({
remote: true,
remoteValidator: 'mycustom';
});
being the equivalent of the example:
<input name="q" type="text" data-parsley-remote data-parsley-remote-validator='mycustom' value="foo" />
after I've registered the example remote:
window.Parsley.addAsyncValidator('mycustom', function (xhr) {
console.log(this.$element);
return 404 === xhr.status;
}, '/api/foo');
When this executes Parsley does try to process the remote inside the internal remote function:
validateString: function validateString(value, url, options, instance) {
While the Parsley.asyncValidators
does include the mycustom
remote OK, the options
parameter is not the options I would expect (it's the Parsely field itself which has those options as an options
property). So options.validator
in this context is null, and so the method picks the default, which isn't configured, and so it errors on url.indexOf
. Anyway that's probably all irrelevant if I've configured it wrong.
I've looked through the documentation, samples and source code, but cannot figure out how these values are read from the config.
Update: I installed it via bower and am using dist/parsely.min.js. I cannot see the parsely.remote.js (mentioned in the docs) anywhere in the bower build so I presume it's all compiled in.