{"action":"closed","issue":{"url":"https://api.github.com/repos/DavyJonesLocker/client_side_validations/issues/639","labels_url":"https://api.github.com/repos/DavyJonesLocker/client_side_validations/issues/639/labels{/name}","comments_url":"https://api.github.com/repos/DavyJonesLocker/client_side_validations/issues/639/comments","events_url":"https://api.github.com/repos/DavyJonesLocker/client_side_validations/issues/639/events","html_url":"https://github.com/DavyJonesLocker/client_side_validations/issues/639","id":116121966,"number":639,"title":"Allow a re-load of the client side validations","user":{"login":"AJFaraday","id":237798,"avatar_url":"https://avatars.githubusercontent.com/u/237798?v=3","gravatar_id":"","url":"https://api.github.com/users/AJFaraday","html_url":"https://github.com/AJFaraday","followers_url":"https://api.github.com/users/AJFaraday/followers","following_url":"https://api.github.com/users/AJFaraday/following{/other_user}","gists_url":"https://api.github.com/users/AJFaraday/gists{/gist_id}","starred_url":"https://api.github.com/users/AJFaraday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AJFaraday/subscriptions","organizations_url":"https://api.github.com/users/AJFaraday/orgs","repos_url":"https://api.github.com/users/AJFaraday/repos","events_url":"https://api.github.com/users/AJFaraday/events{/privacy}","received_events_url":"https://api.github.com/users/AJFaraday/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/DavyJonesLocker/client_side_validations/labels/need%20feedback","name":"need feedback","color":"207de5"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-10T14:54:07Z","updated_at":"2016-01-29T11:51:40Z","closed_at":"2016-01-29T11:51:40Z","body":"I've been working with client side validations in rails 3.0 and discovered that there was no simple way to add validations to any asynchronously loaded forms. (I've had a quick look at the master branch and it doesn't appear to be possible there.\r\n\r\nLocally, I've saved the function at the top of the file in a varable named `clientSideValidationInit` and added this method for removing existing callbacks and re-initialising the client side validation. \r\n\r\n```javascript\r\nreloadClientSideValidations = (function() {\r\n  jQuery('form[data-validate]').find('[data-validators]input')\r\n    .unbind('element:validate:after')\r\n    .unbind('element:validate:before')\r\n    .unbind('element:validate:fail')\r\n    .unbind('element:validate:pass')\r\n  ;\r\n  clientSideValidationInit(jQuery);\r\n});\r\n```\r\n\r\nThis may not be the best approach, but I'd like to see a way to re-init the client side validation, or fill in missing callbacks for async fields."}}