|
|
@@ -12,12 +12,13 @@
|
|
|
* @param {BootstrapValidator} validator Plugin instance
|
|
|
* @param {jQuery} $field Field element
|
|
|
* @param {Object} options Can consist of the following keys:
|
|
|
- * - url
|
|
|
- * - data [optional]: By default, it will take the value
|
|
|
+ * - url {String|Function}
|
|
|
+ * - type {String} [optional] Can be GET or POST (default)
|
|
|
+ * - data {Object|Function} [optional]: By default, it will take the value
|
|
|
* {
|
|
|
* <fieldName>: <fieldValue>
|
|
|
* }
|
|
|
- * - name [optional]: Override the field name for the request.
|
|
|
+ * - name {String} [optional]: Override the field name for the request.
|
|
|
* - message: The invalid message
|
|
|
* @returns {Boolean|Deferred}
|
|
|
*/
|
|
|
@@ -27,19 +28,21 @@
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- var name = $field.attr('data-bv-field'), data = options.data, url = options.url, type = options.type;
|
|
|
- if (type == null || type != "GET") type = "POST";
|
|
|
- if (data == null) {
|
|
|
- data = {};
|
|
|
- }
|
|
|
+ var name = $field.attr('data-bv-field'),
|
|
|
+ data = options.data || {},
|
|
|
+ url = options.url,
|
|
|
+ type = options.type || 'POST';
|
|
|
+
|
|
|
// Support dynamic data
|
|
|
if ('function' == typeof data) {
|
|
|
data = data.call(this, validator);
|
|
|
}
|
|
|
+
|
|
|
// Support dynamic url
|
|
|
if ('function' == typeof url) {
|
|
|
url = url.call(this, validator);
|
|
|
}
|
|
|
+
|
|
|
data[options.name || name] = value;
|
|
|
|
|
|
var dfd = new $.Deferred();
|