{"action":"created","comment":{"url":"https://api.github.com/repos/SumOfUs/Champaign/pulls/comments/53084020","id":53084020,"diff_hunk":"@@ -37,14 +37,23 @@ let ErrorDisplay = {\n   hideError(e) {\n     $(e.target).removeClass('has-error').parent().removeClass('has-error');\n     $(e.target).siblings('.error-msg').remove();\n+    $(e.target).parent('.error-msg').remove();\n   },\n \n   findField(field_name, $form, response) {\n     if (response.name) {\n       field_name = [response.name, '[', field_name, ']'].join('');\n     }\n-    return $form.find(\"[name='\" + field_name + \"']\");\n+    var field = $form.find(\"[name='\" + field_name + \"']\");\n+    if (!field.exists()) {\n+      field = $form.find(':submit').prev();\n+    }\n+    return field\n   },\n }\n \n+$.fn.exists = function () {\n+    return this.length !== 0;","path":"app/assets/javascripts/show_errors.js","position":30,"original_position":30,"commit_id":"3d2f039068cc9f828545b20d43f04c7834ad998b","original_commit_id":"3d2f039068cc9f828545b20d43f04c7834ad998b","user":{"login":"Tuuleh","id":6524052,"avatar_url":"https://avatars.githubusercontent.com/u/6524052?v=3","gravatar_id":"","url":"https://api.github.com/users/Tuuleh","html_url":"https://github.com/Tuuleh","followers_url":"https://api.github.com/users/Tuuleh/followers","following_url":"https://api.github.com/users/Tuuleh/following{/other_user}","gists_url":"https://api.github.com/users/Tuuleh/gists{/gist_id}","starred_url":"https://api.github.com/users/Tuuleh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tuuleh/subscriptions","organizations_url":"https://api.github.com/users/Tuuleh/orgs","repos_url":"https://api.github.com/users/Tuuleh/repos","events_url":"https://api.github.com/users/Tuuleh/events{/privacy}","received_events_url":"https://api.github.com/users/Tuuleh/received_events","type":"User","site_admin":false},"body":"I added this more or less for readability. If element doesn't exist, do x. I can do the same without the function, but it won't be as readable.","created_at":"2016-02-16T21:44:48Z","updated_at":"2016-02-16T21:44:48Z","html_url":"https://github.com/SumOfUs/Champaign/pull/370#discussion_r53084020","pull_request_url":"https://api.github.com/repos/SumOfUs/Champaign/pulls/370","_links":{"self":{"href":"https://api.github.com/repos/SumOfUs/Champaign/pulls/comments/53084020"},"html":{"href":"https://github.com/SumOfUs/Champaign/pull/370#discussion_r53084020"},"pull_request":{"href":"https://api.github.com/repos/SumOfUs/Champaign/pulls/370"}}},"pull_request":{"url":"https://api.github.com/repos/SumOfUs/Champaign/pulls/370","id":59250433,"html_url":"https://github.com/SumOfUs/Champaign/pull/370","diff_url":"https://github.com/SumOfUs/Champaign/pull/370.diff","patch_url":"https://github.com/SumOfUs/Champaign/pull/370.patch","issue_url":"https://api.github.com/repos/SumOfUs/Champaign/issues/370","number":370,"state":"open","locked":false,"title":"Make ErrorDisplay play nicely with ShareProgress errors.","user":{"login":"Tuuleh","id":6524052,"avatar_url":"https://avatars.githubusercontent.com/u/6524052?v=3","gravatar_id":"","url":"https://api.github.com/users/Tuuleh","html_url":"https://github.com/Tuuleh","followers_url":"https://api.github.com/users/Tuuleh/followers","following_url":"https://api.github.com/users/Tuuleh/following{/other_user}","gists_url":"https://api.github.com/users/Tuuleh/gists{/gist_id}","starred_url":"https://api.github.com/users/Tuuleh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tuuleh/subscriptions","organizations_url":"https://api.github.com/users/Tuuleh/orgs","repos_url":"https://api.github.com/users/Tuuleh/repos","events_url":"https://api.github.com/users/Tuuleh/events{/privacy}","received_events_url":"https://api.github.com/users/Tuuleh/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-02-13T00:28:34Z","updated_at":"2016-02-16T21:44:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"60c2db0642a1b857adfc86472ad62acb4de7931b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SumOfUs/Champaign/pulls/370/commits","review_comments_url":"https://api.github.com/repos/SumOfUs/Champaign/pulls/370/comments","review_comment_url":"https://api.github.com/repos/SumOfUs/Champaign/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SumOfUs/Champaign/issues/370/comments","statuses_url":"https://api.github.com/repos/SumOfUs/Champaign/statuses/3d2f039068cc9f828545b20d43f04c7834ad998b","head":{"label":"SumOfUs:shareprogress-errors","ref":"shareprogress-errors","sha":"3d2f039068cc9f828545b20d43f04c7834ad998b","user":{"login":"SumOfUs","id":7574652,"avatar_url":"https://avatars.githubusercontent.com/u/7574652?v=3","gravatar_id":"","url":"https://api.github.com/users/SumOfUs","html_url":"https://github.com/SumOfUs","followers_url":"https://api.github.com/users/SumOfUs/followers","following_url":"https://api.github.com/users/SumOfUs/following{/other_user}","gists_url":"https://api.github.com/users/SumOfUs/gists{/gist_id}","starred_url":"https://api.github.com/users/SumOfUs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SumOfUs/subscriptions","organizations_url":"https://api.github.com/users/SumOfUs/orgs","repos_url":"https://api.github.com/users/SumOfUs/repos","events_url":"https://api.github.com/users/SumOfUs/events{/privacy}","received_events_url":"https://api.github.com/users/SumOfUs/received_events","type":"Organization","site_admin":false},"repo":{"id":33684818,"name":"Champaign","full_name":"SumOfUs/Champaign","owner":{"login":"SumOfUs","id":7574652,"avatar_url":"https://avatars.githubusercontent.com/u/7574652?v=3","gravatar_id":"","url":"https://api.github.com/users/SumOfUs","html_url":"https://github.com/SumOfUs","followers_url":"https://api.github.com/users/SumOfUs/followers","following_url":"https://api.github.com/users/SumOfUs/following{/other_user}","gists_url":"https://api.github.com/users/SumOfUs/gists{/gist_id}","starred_url":"https://api.github.com/users/SumOfUs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SumOfUs/subscriptions","organizations_url":"https://api.github.com/users/SumOfUs/orgs","repos_url":"https://api.github.com/users/SumOfUs/repos","events_url":"https://api.github.com/users/SumOfUs/events{/privacy}","received_events_url":"https://api.github.com/users/SumOfUs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SumOfUs/Champaign","description":"SumOfUs Online Campaign Platform.","fork":false,"url":"https://api.github.com/repos/SumOfUs/Champaign","forks_url":"https://api.github.com/repos/SumOfUs/Champaign/forks","keys_url":"https://api.github.com/repos/SumOfUs/Champaign/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SumOfUs/Champaign/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SumOfUs/Champaign/teams","hooks_url":"https://api.github.com/repos/SumOfUs/Champaign/hooks","issue_events_url":"https://api.github.com/repos/SumOfUs/Champaign/issues/events{/number}","events_url":"https://api.github.com/repos/SumOfUs/Champaign/events","assignees_url":"https://api.github.com/repos/SumOfUs/Champaign/assignees{/user}","branches_url":"https://api.github.com/repos/SumOfUs/Champaign/branches{/branch}","tags_url":"https://api.github.com/repos/SumOfUs/Champaign/tags","blobs_url":"https://api.github.com/repos/SumOfUs/Champaign/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SumOfUs/Champaign/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SumOfUs/Champaign/git/refs{/sha}","trees_url":"https://api.github.com/repos/SumOfUs/Champaign/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SumOfUs/Champaign/statuses/{sha}","languages_url":"https://api.github.com/repos/SumOfUs/Champaign/languages","stargazers_url":"https://api.github.com/repos/SumOfUs/Champaign/stargazers","contributors_url":"https://api.github.com/repos/SumOfUs/Champaign/contributors","subscribers_url":"https://api.github.com/repos/SumOfUs/Champaign/subscribers","subscription_url":"https://api.github.com/repos/SumOfUs/Champaign/subscription","commits_url":"https://api.github.com/repos/SumOfUs/Champaign/commits{/sha}","git_commits_url":"https://api.github.com/repos/SumOfUs/Champaign/git/commits{/sha}","comments_url":"https://api.github.com/repos/SumOfUs/Champaign/comments{/number}","issue_comment_url":"https://api.github.com/repos/SumOfUs/Champaign/issues/comments{/number}","contents_url":"https://api.github.com/repos/SumOfUs/Champaign/contents/{+path}","compare_url":"https://api.github.com/repos/SumOfUs/Champaign/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SumOfUs/Champaign/merges","archive_url":"https://api.github.com/repos/SumOfUs/Champaign/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SumOfUs/Champaign/downloads","issues_url":"https://api.github.com/repos/SumOfUs/Champaign/issues{/number}","pulls_url":"https://api.github.com/repos/SumOfUs/Champaign/pulls{/number}","milestones_url":"https://api.github.com/repos/SumOfUs/Champaign/milestones{/number}","notifications_url":"https://api.github.com/repos/SumOfUs/Champaign/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SumOfUs/Champaign/labels{/name}","releases_url":"https://api.github.com/repos/SumOfUs/Champaign/releases{/id}","deployments_url":"https://api.github.com/repos/SumOfUs/Champaign/deployments","created_at":"2015-04-09T18:16:20Z","updated_at":"2016-01-26T22:39:57Z","pushed_at":"2016-02-16T21:24:02Z","git_url":"git://github.com/SumOfUs/Champaign.git","ssh_url":"git@github.com:SumOfUs/Champaign.git","clone_url":"https://github.com/SumOfUs/Champaign.git","svn_url":"https://github.com/SumOfUs/Champaign","homepage":null,"size":7345,"stargazers_count":11,"watchers_count":11,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":14,"forks":1,"open_issues":14,"watchers":11,"default_branch":"development"}},"base":{"label":"SumOfUs:development","ref":"development","sha":"755eff7c9edaf201a36b46db4efd7e725953c6d5","user":{"login":"SumOfUs","id":7574652,"avatar_url":"https://avatars.githubusercontent.com/u/7574652?v=3","gravatar_id":"","url":"https://api.github.com/users/SumOfUs","html_url":"https://github.com/SumOfUs","followers_url":"https://api.github.com/users/SumOfUs/followers","following_url":"https://api.github.com/users/SumOfUs/following{/other_user}","gists_url":"https://api.github.com/users/SumOfUs/gists{/gist_id}","starred_url":"https://api.github.com/users/SumOfUs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SumOfUs/subscriptions","organizations_url":"https://api.github.com/users/SumOfUs/orgs","repos_url":"https://api.github.com/users/SumOfUs/repos","events_url":"https://api.github.com/users/SumOfUs/events{/privacy}","received_events_url":"https://api.github.com/users/SumOfUs/received_events","type":"Organization","site_admin":false},"repo":{"id":33684818,"name":"Champaign","full_name":"SumOfUs/Champaign","owner":{"login":"SumOfUs","id":7574652,"avatar_url":"https://avatars.githubusercontent.com/u/7574652?v=3","gravatar_id":"","url":"https://api.github.com/users/SumOfUs","html_url":"https://github.com/SumOfUs","followers_url":"https://api.github.com/users/SumOfUs/followers","following_url":"https://api.github.com/users/SumOfUs/following{/other_user}","gists_url":"https://api.github.com/users/SumOfUs/gists{/gist_id}","starred_url":"https://api.github.com/users/SumOfUs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SumOfUs/subscriptions","organizations_url":"https://api.github.com/users/SumOfUs/orgs","repos_url":"https://api.github.com/users/SumOfUs/repos","events_url":"https://api.github.com/users/SumOfUs/events{/privacy}","received_events_url":"https://api.github.com/users/SumOfUs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SumOfUs/Champaign","description":"SumOfUs Online Campaign Platform.","fork":false,"url":"https://api.github.com/repos/SumOfUs/Champaign","forks_url":"https://api.github.com/repos/SumOfUs/Champaign/forks","keys_url":"https://api.github.com/repos/SumOfUs/Champaign/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SumOfUs/Champaign/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SumOfUs/Champaign/teams","hooks_url":"https://api.github.com/repos/SumOfUs/Champaign/hooks","issue_events_url":"https://api.github.com/repos/SumOfUs/Champaign/issues/events{/number}","events_url":"https://api.github.com/repos/SumOfUs/Champaign/events","assignees_url":"https://api.github.com/repos/SumOfUs/Champaign/assignees{/user}","branches_url":"https://api.github.com/repos/SumOfUs/Champaign/branches{/branch}","tags_url":"https://api.github.com/repos/SumOfUs/Champaign/tags","blobs_url":"https://api.github.com/repos/SumOfUs/Champaign/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SumOfUs/Champaign/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SumOfUs/Champaign/git/refs{/sha}","trees_url":"https://api.github.com/repos/SumOfUs/Champaign/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SumOfUs/Champaign/statuses/{sha}","languages_url":"https://api.github.com/repos/SumOfUs/Champaign/languages","stargazers_url":"https://api.github.com/repos/SumOfUs/Champaign/stargazers","contributors_url":"https://api.github.com/repos/SumOfUs/Champaign/contributors","subscribers_url":"https://api.github.com/repos/SumOfUs/Champaign/subscribers","subscription_url":"https://api.github.com/repos/SumOfUs/Champaign/subscription","commits_url":"https://api.github.com/repos/SumOfUs/Champaign/commits{/sha}","git_commits_url":"https://api.github.com/repos/SumOfUs/Champaign/git/commits{/sha}","comments_url":"https://api.github.com/repos/SumOfUs/Champaign/comments{/number}","issue_comment_url":"https://api.github.com/repos/SumOfUs/Champaign/issues/comments{/number}","contents_url":"https://api.github.com/repos/SumOfUs/Champaign/contents/{+path}","compare_url":"https://api.github.com/repos/SumOfUs/Champaign/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SumOfUs/Champaign/merges","archive_url":"https://api.github.com/repos/SumOfUs/Champaign/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SumOfUs/Champaign/downloads","issues_url":"https://api.github.com/repos/SumOfUs/Champaign/issues{/number}","pulls_url":"https://api.github.com/repos/SumOfUs/Champaign/pulls{/number}","milestones_url":"https://api.github.com/repos/SumOfUs/Champaign/milestones{/number}","notifications_url":"https://api.github.com/repos/SumOfUs/Champaign/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SumOfUs/Champaign/labels{/name}","releases_url":"https://api.github.com/repos/SumOfUs/Champaign/releases{/id}","deployments_url":"https://api.github.com/repos/SumOfUs/Champaign/deployments","created_at":"2015-04-09T18:16:20Z","updated_at":"2016-01-26T22:39:57Z","pushed_at":"2016-02-16T21:24:02Z","git_url":"git://github.com/SumOfUs/Champaign.git","ssh_url":"git@github.com:SumOfUs/Champaign.git","clone_url":"https://github.com/SumOfUs/Champaign.git","svn_url":"https://github.com/SumOfUs/Champaign","homepage":null,"size":7345,"stargazers_count":11,"watchers_count":11,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":14,"forks":1,"open_issues":14,"watchers":11,"default_branch":"development"}},"_links":{"self":{"href":"https://api.github.com/repos/SumOfUs/Champaign/pulls/370"},"html":{"href":"https://github.com/SumOfUs/Champaign/pull/370"},"issue":{"href":"https://api.github.com/repos/SumOfUs/Champaign/issues/370"},"comments":{"href":"https://api.github.com/repos/SumOfUs/Champaign/issues/370/comments"},"review_comments":{"href":"https://api.github.com/repos/SumOfUs/Champaign/pulls/370/comments"},"review_comment":{"href":"https://api.github.com/repos/SumOfUs/Champaign/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SumOfUs/Champaign/pulls/370/commits"},"statuses":{"href":"https://api.github.com/repos/SumOfUs/Champaign/statuses/3d2f039068cc9f828545b20d43f04c7834ad998b"}}}}