Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #432 from mjtko/fix/jquery-ready-call

Prevent ReferenceError when rails.validations evaluated after DOM ready
  • Loading branch information...
commit 6ab147d327e1dbd3f31d77e3ec40f531dbbf952d 2 parents 94375eb + 049ce24
@bcardarella bcardarella authored
View
10 coffeescript/rails.validations.coffee
@@ -95,11 +95,6 @@ validateElement = (element, validators) ->
afterValidate()
-# Main hook
-# If new forms are dynamically introduced into the DOM the .validate() method
-# must be invoked on that form
-$(-> $(ClientSideValidations.selectors.forms).validate())
-
if window.ClientSideValidations == undefined
window.ClientSideValidations = {}
@@ -441,3 +436,8 @@ window.ClientSideValidations.callbacks =
before: (form, eventData) ->
fail: (form, eventData) ->
pass: (form, eventData) ->
+
+# Main hook
+# If new forms are dynamically introduced into the DOM the .validate() method
+# must be invoked on that form
+$(-> $(ClientSideValidations.selectors.forms).validate())
View
8 vendor/assets/javascripts/rails.validations.js
@@ -114,10 +114,6 @@
return afterValidate();
};
- $(function() {
- return $(ClientSideValidations.selectors.forms).validate();
- });
-
if (window.ClientSideValidations === void 0) {
window.ClientSideValidations = {};
}
@@ -601,4 +597,8 @@
}
};
+ $(function() {
+ return $(ClientSideValidations.selectors.forms).validate();
+ });
+
}).call(this);
Please sign in to comment.
Something went wrong with that request. Please try again.