{"action":"created","comment":{"url":"https://api.github.com/repos/rails/jquery-ujs/pulls/comments/29161565","id":29161565,"diff_hunk":"@@ -351,18 +343,65 @@\n           $.rails.enableElement(element);\n         }\n       });\n-    });\n+    },\n \n-    $document.delegate(rails.linkDisableSelector, 'ajax:complete', function() {\n-        rails.enableElement($(this));\n-    });\n+    submit: function(e){\n+      var form = $(e.currentTarget),\n+        remote = form.data('remote') !== undefined,\n+        blankRequiredInputs,\n+        nonBlankFileInputs;\n \n-    $document.delegate(rails.buttonDisableSelector, 'ajax:complete', function() {\n-        rails.enableFormElement($(this));\n-    });\n+      if (!rails.allowAction(form)) return rails.stopEverything(e);\n \n-    $document.delegate(rails.linkClickSelector, 'click.rails', function(e) {\n-      var link = $(this), method = link.data('method'), data = link.data('params'), metaClick = e.metaKey || e.ctrlKey;\n+      // skip other logic when required values are missing or file upload is present\n+      if (form.attr('novalidate') == undefined) {\n+        blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector);\n+        if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {\n+          return rails.stopEverything(e);\n+        }\n+      }\n+\n+      if (remote) {\n+        nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);\n+        if (nonBlankFileInputs) {\n+          // slight timeout so that the submit button gets properly serialized\n+          // (make it easy for event handler to serialize form without disabled values)\n+          setTimeout(function(){ rails.disableFormElements(form); }, 13);\n+          var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);\n+\n+          // re-enable form elements if event bindings return false (canceling normal form submission)\n+          if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); }\n+\n+          return aborted;\n+        }\n+\n+        rails.handleRemote(form);\n+        return false;\n+\n+      } else {\n+        // slight timeout so that the submit button gets properly serialized\n+        setTimeout(function(){ rails.disableFormElements(form); }, 13);","path":"src/rails.js","position":69,"original_position":69,"commit_id":"b334fe299c47f67a660a7262971ef1365321793f","original_commit_id":"b334fe299c47f67a660a7262971ef1365321793f","user":{"login":"rafaelfranca","id":47848,"avatar_url":"https://avatars.githubusercontent.com/u/47848?v=3","gravatar_id":"","url":"https://api.github.com/users/rafaelfranca","html_url":"https://github.com/rafaelfranca","followers_url":"https://api.github.com/users/rafaelfranca/followers","following_url":"https://api.github.com/users/rafaelfranca/following{/other_user}","gists_url":"https://api.github.com/users/rafaelfranca/gists{/gist_id}","starred_url":"https://api.github.com/users/rafaelfranca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafaelfranca/subscriptions","organizations_url":"https://api.github.com/users/rafaelfranca/orgs","repos_url":"https://api.github.com/users/rafaelfranca/repos","events_url":"https://api.github.com/users/rafaelfranca/events{/privacy}","received_events_url":"https://api.github.com/users/rafaelfranca/received_events","type":"User","site_admin":false},"body":"space after the `)` of `function`","created_at":"2015-04-27T16:12:28Z","updated_at":"2015-04-27T16:12:28Z","html_url":"https://github.com/rails/jquery-ujs/pull/413#discussion_r29161565","pull_request_url":"https://api.github.com/repos/rails/jquery-ujs/pulls/413","_links":{"self":{"href":"https://api.github.com/repos/rails/jquery-ujs/pulls/comments/29161565"},"html":{"href":"https://github.com/rails/jquery-ujs/pull/413#discussion_r29161565"},"pull_request":{"href":"https://api.github.com/repos/rails/jquery-ujs/pulls/413"}}},"pull_request":{"url":"https://api.github.com/repos/rails/jquery-ujs/pulls/413","id":34177394,"html_url":"https://github.com/rails/jquery-ujs/pull/413","diff_url":"https://github.com/rails/jquery-ujs/pull/413.diff","patch_url":"https://github.com/rails/jquery-ujs/pull/413.patch","issue_url":"https://api.github.com/repos/rails/jquery-ujs/issues/413","number":413,"state":"open","locked":false,"title":"Moves event delegation to namespaced object","user":{"login":"stevenwanderski","id":473336,"avatar_url":"https://avatars.githubusercontent.com/u/473336?v=3","gravatar_id":"","url":"https://api.github.com/users/stevenwanderski","html_url":"https://github.com/stevenwanderski","followers_url":"https://api.github.com/users/stevenwanderski/followers","following_url":"https://api.github.com/users/stevenwanderski/following{/other_user}","gists_url":"https://api.github.com/users/stevenwanderski/gists{/gist_id}","starred_url":"https://api.github.com/users/stevenwanderski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevenwanderski/subscriptions","organizations_url":"https://api.github.com/users/stevenwanderski/orgs","repos_url":"https://api.github.com/users/stevenwanderski/repos","events_url":"https://api.github.com/users/stevenwanderski/events{/privacy}","received_events_url":"https://api.github.com/users/stevenwanderski/received_events","type":"User","site_admin":false},"body":"Moving event handlers to a public namespace allows the handlers to be overriden by plugins.","created_at":"2015-04-27T15:01:59Z","updated_at":"2015-04-27T16:12:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f5b0b37a17a682560b8a95befd6356d4f2d72aa2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rails/jquery-ujs/pulls/413/commits","review_comments_url":"https://api.github.com/repos/rails/jquery-ujs/pulls/413/comments","review_comment_url":"https://api.github.com/repos/rails/jquery-ujs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/jquery-ujs/issues/413/comments","statuses_url":"https://api.github.com/repos/rails/jquery-ujs/statuses/b334fe299c47f67a660a7262971ef1365321793f","head":{"label":"stevenwanderski:overridable-event-handlers","ref":"overridable-event-handlers","sha":"b334fe299c47f67a660a7262971ef1365321793f","user":{"login":"stevenwanderski","id":473336,"avatar_url":"https://avatars.githubusercontent.com/u/473336?v=3","gravatar_id":"","url":"https://api.github.com/users/stevenwanderski","html_url":"https://github.com/stevenwanderski","followers_url":"https://api.github.com/users/stevenwanderski/followers","following_url":"https://api.github.com/users/stevenwanderski/following{/other_user}","gists_url":"https://api.github.com/users/stevenwanderski/gists{/gist_id}","starred_url":"https://api.github.com/users/stevenwanderski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevenwanderski/subscriptions","organizations_url":"https://api.github.com/users/stevenwanderski/orgs","repos_url":"https://api.github.com/users/stevenwanderski/repos","events_url":"https://api.github.com/users/stevenwanderski/events{/privacy}","received_events_url":"https://api.github.com/users/stevenwanderski/received_events","type":"User","site_admin":false},"repo":{"id":34669441,"name":"jquery-ujs","full_name":"stevenwanderski/jquery-ujs","owner":{"login":"stevenwanderski","id":473336,"avatar_url":"https://avatars.githubusercontent.com/u/473336?v=3","gravatar_id":"","url":"https://api.github.com/users/stevenwanderski","html_url":"https://github.com/stevenwanderski","followers_url":"https://api.github.com/users/stevenwanderski/followers","following_url":"https://api.github.com/users/stevenwanderski/following{/other_user}","gists_url":"https://api.github.com/users/stevenwanderski/gists{/gist_id}","starred_url":"https://api.github.com/users/stevenwanderski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevenwanderski/subscriptions","organizations_url":"https://api.github.com/users/stevenwanderski/orgs","repos_url":"https://api.github.com/users/stevenwanderski/repos","events_url":"https://api.github.com/users/stevenwanderski/events{/privacy}","received_events_url":"https://api.github.com/users/stevenwanderski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/stevenwanderski/jquery-ujs","description":"Ruby on Rails unobtrusive scripting adapter for jQuery","fork":true,"url":"https://api.github.com/repos/stevenwanderski/jquery-ujs","forks_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/forks","keys_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/teams","hooks_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/hooks","issue_events_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/issues/events{/number}","events_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/events","assignees_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/assignees{/user}","branches_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/branches{/branch}","tags_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/tags","blobs_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/git/refs{/sha}","trees_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/statuses/{sha}","languages_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/languages","stargazers_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/stargazers","contributors_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/contributors","subscribers_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/subscribers","subscription_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/subscription","commits_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/commits{/sha}","git_commits_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/git/commits{/sha}","comments_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/comments{/number}","issue_comment_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/issues/comments{/number}","contents_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/contents/{+path}","compare_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/merges","archive_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/downloads","issues_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/issues{/number}","pulls_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/pulls{/number}","milestones_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/milestones{/number}","notifications_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/labels{/name}","releases_url":"https://api.github.com/repos/stevenwanderski/jquery-ujs/releases{/id}","created_at":"2015-04-27T13:50:38Z","updated_at":"2015-04-27T13:50:38Z","pushed_at":"2015-04-27T14:51:28Z","git_url":"git://github.com/stevenwanderski/jquery-ujs.git","ssh_url":"git@github.com:stevenwanderski/jquery-ujs.git","clone_url":"https://github.com/stevenwanderski/jquery-ujs.git","svn_url":"https://github.com/stevenwanderski/jquery-ujs","homepage":"","size":695,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rails:master","ref":"master","sha":"75f7094dc6827585e0ab19d8777b9133b69895af","user":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":494159,"name":"jquery-ujs","full_name":"rails/jquery-ujs","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/jquery-ujs","description":"Ruby on Rails unobtrusive scripting adapter for jQuery","fork":false,"url":"https://api.github.com/repos/rails/jquery-ujs","forks_url":"https://api.github.com/repos/rails/jquery-ujs/forks","keys_url":"https://api.github.com/repos/rails/jquery-ujs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/jquery-ujs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/jquery-ujs/teams","hooks_url":"https://api.github.com/repos/rails/jquery-ujs/hooks","issue_events_url":"https://api.github.com/repos/rails/jquery-ujs/issues/events{/number}","events_url":"https://api.github.com/repos/rails/jquery-ujs/events","assignees_url":"https://api.github.com/repos/rails/jquery-ujs/assignees{/user}","branches_url":"https://api.github.com/repos/rails/jquery-ujs/branches{/branch}","tags_url":"https://api.github.com/repos/rails/jquery-ujs/tags","blobs_url":"https://api.github.com/repos/rails/jquery-ujs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/jquery-ujs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/jquery-ujs/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/jquery-ujs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/jquery-ujs/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/jquery-ujs/languages","stargazers_url":"https://api.github.com/repos/rails/jquery-ujs/stargazers","contributors_url":"https://api.github.com/repos/rails/jquery-ujs/contributors","subscribers_url":"https://api.github.com/repos/rails/jquery-ujs/subscribers","subscription_url":"https://api.github.com/repos/rails/jquery-ujs/subscription","commits_url":"https://api.github.com/repos/rails/jquery-ujs/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/jquery-ujs/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/jquery-ujs/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/jquery-ujs/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails/jquery-ujs/contents/{+path}","compare_url":"https://api.github.com/repos/rails/jquery-ujs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/jquery-ujs/merges","archive_url":"https://api.github.com/repos/rails/jquery-ujs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/jquery-ujs/downloads","issues_url":"https://api.github.com/repos/rails/jquery-ujs/issues{/number}","pulls_url":"https://api.github.com/repos/rails/jquery-ujs/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/jquery-ujs/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/jquery-ujs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/jquery-ujs/labels{/name}","releases_url":"https://api.github.com/repos/rails/jquery-ujs/releases{/id}","created_at":"2010-01-29T20:18:24Z","updated_at":"2015-04-27T09:35:42Z","pushed_at":"2015-04-27T15:02:00Z","git_url":"git://github.com/rails/jquery-ujs.git","ssh_url":"git@github.com:rails/jquery-ujs.git","clone_url":"https://github.com/rails/jquery-ujs.git","svn_url":"https://github.com/rails/jquery-ujs","homepage":"","size":1988,"stargazers_count":2137,"watchers_count":2137,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":419,"mirror_url":null,"open_issues_count":54,"forks":419,"open_issues":54,"watchers":2137,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/jquery-ujs/pulls/413"},"html":{"href":"https://github.com/rails/jquery-ujs/pull/413"},"issue":{"href":"https://api.github.com/repos/rails/jquery-ujs/issues/413"},"comments":{"href":"https://api.github.com/repos/rails/jquery-ujs/issues/413/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/jquery-ujs/pulls/413/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/jquery-ujs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/jquery-ujs/pulls/413/commits"},"statuses":{"href":"https://api.github.com/repos/rails/jquery-ujs/statuses/b334fe299c47f67a660a7262971ef1365321793f"}}}}