浏览代码

Improve fixes for #223

nghuuphuoc 11 年之前
父节点
当前提交
1a4dd7c282
共有 3 个文件被更改,包括 8 次插入8 次删除
  1. 3 3
      dist/js/bootstrapValidator.js
  2. 2 2
      dist/js/bootstrapValidator.min.js
  3. 3 3
      src/js/bootstrapValidator.js

+ 3 - 3
dist/js/bootstrapValidator.js

@@ -217,7 +217,7 @@
                     };
 
                     // Check if there is any validators set using HTML attributes
-                    if (!$.isEmptyObject(opts)) {
+                    if (!$.isEmptyObject(opts.validators) && !$.isEmptyObject(opts)) {
                         $field.attr('data-bv-field', field);
                         options.fields[field] = $.extend({}, opts, options.fields[field]);
                     }
@@ -309,7 +309,7 @@
                     && (!updateAll || i == total - 1))
                 {
                     $parent.addClass('has-feedback');
-                    var $icon = $('<i/>').css('display', 'none').addClass('form-control-feedback').attr('data-bv-icon', field).insertAfter($field);
+                    var $icon = $('<i/>').css('display', 'none').addClass('form-control-feedback').attr('data-bv-icon-for', field).insertAfter($field);
                     // The feedback icon does not render correctly if there is no label
                     // https://github.com/twbs/bootstrap/issues/12873
                     if ($parent.find('label').length == 0) {
@@ -627,7 +627,7 @@
                 $parent  = $field.parents('.form-group'),
                 $message = $field.data('bv.messages'),
                 $errors  = $message.find('.help-block[data-bv-validator]'),
-                $icon    = $parent.find('.form-control-feedback[data-bv-icon="' + field + '"]');
+                $icon    = $parent.find('.form-control-feedback[data-bv-icon-for="' + field + '"]');
 
             // Update status
             if (validatorName) {

文件差异内容过多而无法显示
+ 2 - 2
dist/js/bootstrapValidator.min.js


+ 3 - 3
src/js/bootstrapValidator.js

@@ -216,7 +216,7 @@
                     };
 
                     // Check if there is any validators set using HTML attributes
-                    if (!$.isEmptyObject(opts)) {
+                    if (!$.isEmptyObject(opts.validators) && !$.isEmptyObject(opts)) {
                         $field.attr('data-bv-field', field);
                         options.fields[field] = $.extend({}, opts, options.fields[field]);
                     }
@@ -308,7 +308,7 @@
                     && (!updateAll || i == total - 1))
                 {
                     $parent.addClass('has-feedback');
-                    var $icon = $('<i/>').css('display', 'none').addClass('form-control-feedback').attr('data-bv-icon', field).insertAfter($field);
+                    var $icon = $('<i/>').css('display', 'none').addClass('form-control-feedback').attr('data-bv-icon-for', field).insertAfter($field);
                     // The feedback icon does not render correctly if there is no label
                     // https://github.com/twbs/bootstrap/issues/12873
                     if ($parent.find('label').length == 0) {
@@ -626,7 +626,7 @@
                 $parent  = $field.parents('.form-group'),
                 $message = $field.data('bv.messages'),
                 $errors  = $message.find('.help-block[data-bv-validator]'),
-                $icon    = $parent.find('.form-control-feedback[data-bv-icon="' + field + '"]');
+                $icon    = $parent.find('.form-control-feedback[data-bv-icon-for="' + field + '"]');
 
             // Update status
             if (validatorName) {