Skip to content
Browse files

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

Prevent ReferenceError when rails.validations evaluated after DOM ready
  • Loading branch information...
2 parents 94375eb + 049ce24 commit 6ab147d327e1dbd3f31d77e3ec40f531dbbf952d @bcardarella bcardarella committed
Showing with 9 additions and 9 deletions.
  1. +5 −5 coffeescript/rails.validations.coffee
  2. +4 −4 vendor/assets/javascripts/rails.validations.js
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);

0 comments on commit 6ab147d

Please sign in to comment.
Something went wrong with that request. Please try again.