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 @@
-
+
See this blog entry for more information.
Here are some links in a normal paragraph: Google,
diff --git a/test/test.js b/test/test.js
index 51a79f2..6f099e0 100644
--- a/test/test.js
+++ b/test/test.js
@@ -574,15 +574,9 @@ test("findLastActive()", function() {
ok( !v.findLastActive() );
v.form();
v.focusInvalid();
- ok( !v.findLastActive() );
- try {
- $("#testForm1 input:last").trigger("focusin");
- //$("#testForm1").triggerEvent("focusin", $("#testForm1 input:last")[0]);
- v.focusInvalid();
- equals( lastInput, v.findLastActive() );
- } catch(e) {
- ok( true, "Ignore in IE" );
- }
+ equals( v.findLastActive(), $("#firstname")[0] );
+ var lastActive = $("#lastname").trigger("validatefocusin")[0];
+ equals( v.findLastActive(), lastActive );
});
test("validating multiple checkboxes with 'required'", function() {
@@ -877,7 +871,7 @@ test("validate on blur", function() {
equals(v.errors().filter(":visible").size(), expected);
}
function blur(target) {
- target.trigger("focusout");
+ target.trigger("validatefocusout");
}
$("#errorFirstname").hide();
var e = $("#firstname");
@@ -954,7 +948,7 @@ test("validate on not keyup, only blur", function() {
e.trigger("keyup");
e.keyup();
errors(0);
- e.trigger("focusout");
+ e.trigger("validatefocusout");
errors(1);
});
@@ -968,7 +962,7 @@ test("validate on keyup and blur", function() {
e.val("a");
e.trigger("keyup");
errors(0);
- e.trigger("focusout");
+ e.trigger("validatefocusout");
errors(1);
});