diff --git a/changelog.txt b/changelog.txt index bf6e656..8aef550 100644 --- a/changelog.txt +++ b/changelog.txt @@ -11,6 +11,7 @@ * Renamed phone-method in additional-methods.js to phoneUS * Added phoneUK and mobileUK methods to additional-methods.js (http://plugins.jquery.com/node/12359) * Deep extend options to avoid modifying multiple forms when using the rules-method on a single element (http://plugins.jquery.com/node/12411) +* Bugfixes for compability with jQuery 1.4.2, while maintaining backwards-compability 1.6 --- diff --git a/jquery.validate.js b/jquery.validate.js index dc4637f..b8d39e3 100644 --- a/jquery.validate.js +++ b/jquery.validate.js @@ -300,12 +300,13 @@ $.extend($.validator, { }); function delegate(event) { - var validator = $.data(this[0].form, "validator"); - validator.settings["on" + event.type] && validator.settings["on" + event.type].call(validator, this[0] ); + var validator = $.data(this[0].form, "validator"), + eventType = "on" + event.type.replace(/^validate/, ""); + validator.settings[eventType] && validator.settings[eventType].call(validator, this[0] ); } $(this.currentForm) - .delegate("focusin focusout keyup", ":text, :password, :file, select, textarea", delegate) - .delegate("click", ":radio, :checkbox, select, option", delegate); + .validateDelegate(":text, :password, :file, select, textarea", "validatefocusin validatefocusout keyup", delegate) + .validateDelegate(":radio, :checkbox, select, option", "click", delegate); if (this.settings.invalidHandler) $(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler); @@ -1104,8 +1105,8 @@ $.format = $.validator.format; // provides triggerEvent(type: String, target: Element) to trigger delegated events ;(function($) { $.each({ - focus: 'focusin', - blur: 'focusout' + focus: 'validatefocusin', + blur: 'validatefocusout' }, function( original, fix ){ $.event.special[fix] = { setup:function() { @@ -1125,16 +1126,13 @@ $.format = $.validator.format; }; }); $.extend($.fn, { - delegate: function(type, delegate, handler) { + validateDelegate: function(delegate, type, handler) { return this.bind(type, function(event) { var target = $(event.target); if (target.is(delegate)) { return handler.apply(target, arguments); } }); - }, - triggerEvent: function(type, target) { - return this.triggerHandler(type, [$.event.fix({ type: type, target: target })]); } }); })(jQuery); diff --git a/test/index.html b/test/index.html index b52dd3d..fc70450 100644 --- a/test/index.html +++ b/test/index.html @@ -24,7 +24,7 @@ -