{"action":"created","comment":{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/pulls/comments/56398064","id":56398064,"diff_hunk":"@@ -126,18 +126,60 @@ Marionette.View = Marionette.AbstractView.extend({\n \n     // Add the regions definitions to the regions property\n     this.regions = _.extend({}, this.regions, regions);\n+    this._regionEvents = {};\n \n     return this._buildRegions(regions);\n   },\n \n   // Remove a single region from the LayoutView, by name\n   removeRegion: function(name) {\n+    this._unbindRegionEvents(name);\n     delete this.regions[name];\n     return this.regionManager.removeRegion(name);\n   },\n-\n+  _bindRegionEvents: function(regionName, childView) {\n+    var childEvents = this.getOption('childEvents');\n+    var normalizedChildEvents = this.normalizeMethods(childEvents);\n+\n+    var regionEvents = {};\n+\n+    // determine if there is a region alias that needs to be bound\n+    _.each(normalizedChildEvents, function(eventHandler, childEventName) {\n+        var regionEventSplitter = /^(@region\\.(.*?)\\s+)?\\s*(.*)$/;\n+        var match = childEventName.match(regionEventSplitter);\n+        var regionAlias = match[2];\n+        var regionEventName = match[3];\n+\n+        // is there a valid region alias event bound to this childView\n+        var validRegionEvent = _.isString(regionAlias) && regionAlias === regionName;\n+\n+        if (_.isFunction(eventHandler) && validRegionEvent) {\n+          regionEvents[regionEventName] = function() {\n+            var args = Array.prototype.slice.call(arguments);\n+            eventHandler.apply(this, [childView].concat(args));\n+          };","path":"src/view.js","position":36,"original_position":36,"commit_id":"ea1743ec0a6182056b87544e872d0cda746d5aea","original_commit_id":"ea1743ec0a6182056b87544e872d0cda746d5aea","user":{"login":"maniator","id":539579,"avatar_url":"https://avatars.githubusercontent.com/u/539579?v=3","gravatar_id":"","url":"https://api.github.com/users/maniator","html_url":"https://github.com/maniator","followers_url":"https://api.github.com/users/maniator/followers","following_url":"https://api.github.com/users/maniator/following{/other_user}","gists_url":"https://api.github.com/users/maniator/gists{/gist_id}","starred_url":"https://api.github.com/users/maniator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maniator/subscriptions","organizations_url":"https://api.github.com/users/maniator/orgs","repos_url":"https://api.github.com/users/maniator/repos","events_url":"https://api.github.com/users/maniator/events{/privacy}","received_events_url":"https://api.github.com/users/maniator/received_events","type":"User","site_admin":false},"body":"or can even do:\r\n\r\n    regionEvents[regionEventName] = function(...args) {\r\n        eventHandler.apply(this, [childView, ...args]);\r\n    } \r\n\r\nWhich would work too :-)\r\n","created_at":"2016-03-16T19:19:58Z","updated_at":"2016-03-16T19:19:58Z","html_url":"https://github.com/marionettejs/backbone.marionette/pull/2819#discussion_r56398064","pull_request_url":"https://api.github.com/repos/marionettejs/backbone.marionette/pulls/2819","_links":{"self":{"href":"https://api.github.com/repos/marionettejs/backbone.marionette/pulls/comments/56398064"},"html":{"href":"https://github.com/marionettejs/backbone.marionette/pull/2819#discussion_r56398064"},"pull_request":{"href":"https://api.github.com/repos/marionettejs/backbone.marionette/pulls/2819"}}},"pull_request":{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/pulls/2819","id":50540230,"html_url":"https://github.com/marionettejs/backbone.marionette/pull/2819","diff_url":"https://github.com/marionettejs/backbone.marionette/pull/2819.diff","patch_url":"https://github.com/marionettejs/backbone.marionette/pull/2819.patch","issue_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2819","number":2819,"state":"open","locked":false,"title":"Adding region aliases into childEvents hash","user":{"login":"msiconolfi","id":2567736,"avatar_url":"https://avatars.githubusercontent.com/u/2567736?v=3","gravatar_id":"","url":"https://api.github.com/users/msiconolfi","html_url":"https://github.com/msiconolfi","followers_url":"https://api.github.com/users/msiconolfi/followers","following_url":"https://api.github.com/users/msiconolfi/following{/other_user}","gists_url":"https://api.github.com/users/msiconolfi/gists{/gist_id}","starred_url":"https://api.github.com/users/msiconolfi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msiconolfi/subscriptions","organizations_url":"https://api.github.com/users/msiconolfi/orgs","repos_url":"https://api.github.com/users/msiconolfi/repos","events_url":"https://api.github.com/users/msiconolfi/events{/privacy}","received_events_url":"https://api.github.com/users/msiconolfi/received_events","type":"User","site_admin":false},"body":"Preliminary enhancement for supporting region aliases in the `View.childEvents` hash, as requested in [Issue 2763](https://github.com/marionettejs/backbone.marionette/issues/2783).\r\n\r\n- Moved layout specific logic out of `AbstractView` and into `View` object, and simply calling `layoutView.triggerChildEvents(eventName, this, args);` from inside `AbstractView._triggerEventOnParentLayout`; to me this seems to separate the logic a little better, and also provides a hook for subclasses to override if needed.\r\n- Added region alias detection to determine if the current view is the one specified in the `childEvents` hash, non-region aliases should behave the same as in earlier releases.\r\n\r\n","created_at":"2015-11-12T17:20:40Z","updated_at":"2016-03-16T19:19:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/milestones/26","html_url":"https://github.com/marionettejs/backbone.marionette/milestones/v3.x","labels_url":"https://api.github.com/repos/marionettejs/backbone.marionette/milestones/26/labels","id":817886,"number":26,"title":"v3.x","description":null,"creator":{"login":"jmeas","id":2322305,"avatar_url":"https://avatars.githubusercontent.com/u/2322305?v=3","gravatar_id":"","url":"https://api.github.com/users/jmeas","html_url":"https://github.com/jmeas","followers_url":"https://api.github.com/users/jmeas/followers","following_url":"https://api.github.com/users/jmeas/following{/other_user}","gists_url":"https://api.github.com/users/jmeas/gists{/gist_id}","starred_url":"https://api.github.com/users/jmeas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmeas/subscriptions","organizations_url":"https://api.github.com/users/jmeas/orgs","repos_url":"https://api.github.com/users/jmeas/repos","events_url":"https://api.github.com/users/jmeas/events{/privacy}","received_events_url":"https://api.github.com/users/jmeas/received_events","type":"User","site_admin":false},"open_issues":42,"closed_issues":25,"state":"open","created_at":"2014-10-08T04:44:25Z","updated_at":"2016-03-16T18:00:15Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/marionettejs/backbone.marionette/pulls/2819/commits","review_comments_url":"https://api.github.com/repos/marionettejs/backbone.marionette/pulls/2819/comments","review_comment_url":"https://api.github.com/repos/marionettejs/backbone.marionette/pulls/comments{/number}","comments_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2819/comments","statuses_url":"https://api.github.com/repos/marionettejs/backbone.marionette/statuses/ea1743ec0a6182056b87544e872d0cda746d5aea","head":{"label":"msiconolfi:region-filtering-child-events","ref":"region-filtering-child-events","sha":"ea1743ec0a6182056b87544e872d0cda746d5aea","user":{"login":"msiconolfi","id":2567736,"avatar_url":"https://avatars.githubusercontent.com/u/2567736?v=3","gravatar_id":"","url":"https://api.github.com/users/msiconolfi","html_url":"https://github.com/msiconolfi","followers_url":"https://api.github.com/users/msiconolfi/followers","following_url":"https://api.github.com/users/msiconolfi/following{/other_user}","gists_url":"https://api.github.com/users/msiconolfi/gists{/gist_id}","starred_url":"https://api.github.com/users/msiconolfi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msiconolfi/subscriptions","organizations_url":"https://api.github.com/users/msiconolfi/orgs","repos_url":"https://api.github.com/users/msiconolfi/repos","events_url":"https://api.github.com/users/msiconolfi/events{/privacy}","received_events_url":"https://api.github.com/users/msiconolfi/received_events","type":"User","site_admin":false},"repo":{"id":45130014,"name":"backbone.marionette","full_name":"msiconolfi/backbone.marionette","owner":{"login":"msiconolfi","id":2567736,"avatar_url":"https://avatars.githubusercontent.com/u/2567736?v=3","gravatar_id":"","url":"https://api.github.com/users/msiconolfi","html_url":"https://github.com/msiconolfi","followers_url":"https://api.github.com/users/msiconolfi/followers","following_url":"https://api.github.com/users/msiconolfi/following{/other_user}","gists_url":"https://api.github.com/users/msiconolfi/gists{/gist_id}","starred_url":"https://api.github.com/users/msiconolfi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msiconolfi/subscriptions","organizations_url":"https://api.github.com/users/msiconolfi/orgs","repos_url":"https://api.github.com/users/msiconolfi/repos","events_url":"https://api.github.com/users/msiconolfi/events{/privacy}","received_events_url":"https://api.github.com/users/msiconolfi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/msiconolfi/backbone.marionette","description":"The Backbone Framework","fork":true,"url":"https://api.github.com/repos/msiconolfi/backbone.marionette","forks_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/forks","keys_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/keys{/key_id}","collaborators_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/teams","hooks_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/hooks","issue_events_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/issues/events{/number}","events_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/events","assignees_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/assignees{/user}","branches_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/branches{/branch}","tags_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/tags","blobs_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/git/refs{/sha}","trees_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/git/trees{/sha}","statuses_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/statuses/{sha}","languages_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/languages","stargazers_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/stargazers","contributors_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/contributors","subscribers_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/subscribers","subscription_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/subscription","commits_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/commits{/sha}","git_commits_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/git/commits{/sha}","comments_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/comments{/number}","issue_comment_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/issues/comments{/number}","contents_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/contents/{+path}","compare_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/compare/{base}...{head}","merges_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/merges","archive_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/downloads","issues_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/issues{/number}","pulls_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/pulls{/number}","milestones_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/milestones{/number}","notifications_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/labels{/name}","releases_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/releases{/id}","deployments_url":"https://api.github.com/repos/msiconolfi/backbone.marionette/deployments","created_at":"2015-10-28T17:29:33Z","updated_at":"2015-10-28T17:29:36Z","pushed_at":"2015-12-01T14:46:38Z","git_url":"git://github.com/msiconolfi/backbone.marionette.git","ssh_url":"git@github.com:msiconolfi/backbone.marionette.git","clone_url":"https://github.com/msiconolfi/backbone.marionette.git","svn_url":"https://github.com/msiconolfi/backbone.marionette","homepage":"http://marionettejs.com","size":10861,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"marionettejs:next","ref":"next","sha":"014586ecafd81f8150dcc4e20d1aa6bdc9fed5fd","user":{"login":"marionettejs","id":2273169,"avatar_url":"https://avatars.githubusercontent.com/u/2273169?v=3","gravatar_id":"","url":"https://api.github.com/users/marionettejs","html_url":"https://github.com/marionettejs","followers_url":"https://api.github.com/users/marionettejs/followers","following_url":"https://api.github.com/users/marionettejs/following{/other_user}","gists_url":"https://api.github.com/users/marionettejs/gists{/gist_id}","starred_url":"https://api.github.com/users/marionettejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marionettejs/subscriptions","organizations_url":"https://api.github.com/users/marionettejs/orgs","repos_url":"https://api.github.com/users/marionettejs/repos","events_url":"https://api.github.com/users/marionettejs/events{/privacy}","received_events_url":"https://api.github.com/users/marionettejs/received_events","type":"Organization","site_admin":false},"repo":{"id":2965621,"name":"backbone.marionette","full_name":"marionettejs/backbone.marionette","owner":{"login":"marionettejs","id":2273169,"avatar_url":"https://avatars.githubusercontent.com/u/2273169?v=3","gravatar_id":"","url":"https://api.github.com/users/marionettejs","html_url":"https://github.com/marionettejs","followers_url":"https://api.github.com/users/marionettejs/followers","following_url":"https://api.github.com/users/marionettejs/following{/other_user}","gists_url":"https://api.github.com/users/marionettejs/gists{/gist_id}","starred_url":"https://api.github.com/users/marionettejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marionettejs/subscriptions","organizations_url":"https://api.github.com/users/marionettejs/orgs","repos_url":"https://api.github.com/users/marionettejs/repos","events_url":"https://api.github.com/users/marionettejs/events{/privacy}","received_events_url":"https://api.github.com/users/marionettejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/marionettejs/backbone.marionette","description":"The Backbone Framework","fork":false,"url":"https://api.github.com/repos/marionettejs/backbone.marionette","forks_url":"https://api.github.com/repos/marionettejs/backbone.marionette/forks","keys_url":"https://api.github.com/repos/marionettejs/backbone.marionette/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marionettejs/backbone.marionette/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marionettejs/backbone.marionette/teams","hooks_url":"https://api.github.com/repos/marionettejs/backbone.marionette/hooks","issue_events_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/events{/number}","events_url":"https://api.github.com/repos/marionettejs/backbone.marionette/events","assignees_url":"https://api.github.com/repos/marionettejs/backbone.marionette/assignees{/user}","branches_url":"https://api.github.com/repos/marionettejs/backbone.marionette/branches{/branch}","tags_url":"https://api.github.com/repos/marionettejs/backbone.marionette/tags","blobs_url":"https://api.github.com/repos/marionettejs/backbone.marionette/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marionettejs/backbone.marionette/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marionettejs/backbone.marionette/git/refs{/sha}","trees_url":"https://api.github.com/repos/marionettejs/backbone.marionette/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marionettejs/backbone.marionette/statuses/{sha}","languages_url":"https://api.github.com/repos/marionettejs/backbone.marionette/languages","stargazers_url":"https://api.github.com/repos/marionettejs/backbone.marionette/stargazers","contributors_url":"https://api.github.com/repos/marionettejs/backbone.marionette/contributors","subscribers_url":"https://api.github.com/repos/marionettejs/backbone.marionette/subscribers","subscription_url":"https://api.github.com/repos/marionettejs/backbone.marionette/subscription","commits_url":"https://api.github.com/repos/marionettejs/backbone.marionette/commits{/sha}","git_commits_url":"https://api.github.com/repos/marionettejs/backbone.marionette/git/commits{/sha}","comments_url":"https://api.github.com/repos/marionettejs/backbone.marionette/comments{/number}","issue_comment_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/comments{/number}","contents_url":"https://api.github.com/repos/marionettejs/backbone.marionette/contents/{+path}","compare_url":"https://api.github.com/repos/marionettejs/backbone.marionette/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marionettejs/backbone.marionette/merges","archive_url":"https://api.github.com/repos/marionettejs/backbone.marionette/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marionettejs/backbone.marionette/downloads","issues_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues{/number}","pulls_url":"https://api.github.com/repos/marionettejs/backbone.marionette/pulls{/number}","milestones_url":"https://api.github.com/repos/marionettejs/backbone.marionette/milestones{/number}","notifications_url":"https://api.github.com/repos/marionettejs/backbone.marionette/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marionettejs/backbone.marionette/labels{/name}","releases_url":"https://api.github.com/repos/marionettejs/backbone.marionette/releases{/id}","deployments_url":"https://api.github.com/repos/marionettejs/backbone.marionette/deployments","created_at":"2011-12-12T16:36:09Z","updated_at":"2016-03-16T13:49:35Z","pushed_at":"2016-03-16T18:24:00Z","git_url":"git://github.com/marionettejs/backbone.marionette.git","ssh_url":"git@github.com:marionettejs/backbone.marionette.git","clone_url":"https://github.com/marionettejs/backbone.marionette.git","svn_url":"https://github.com/marionettejs/backbone.marionette","homepage":"http://marionettejs.com","size":18564,"stargazers_count":6772,"watchers_count":6772,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1342,"mirror_url":null,"open_issues_count":104,"forks":1342,"open_issues":104,"watchers":6772,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/marionettejs/backbone.marionette/pulls/2819"},"html":{"href":"https://github.com/marionettejs/backbone.marionette/pull/2819"},"issue":{"href":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2819"},"comments":{"href":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2819/comments"},"review_comments":{"href":"https://api.github.com/repos/marionettejs/backbone.marionette/pulls/2819/comments"},"review_comment":{"href":"https://api.github.com/repos/marionettejs/backbone.marionette/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/marionettejs/backbone.marionette/pulls/2819/commits"},"statuses":{"href":"https://api.github.com/repos/marionettejs/backbone.marionette/statuses/ea1743ec0a6182056b87544e872d0cda746d5aea"}}}}