{"action":"closed","issue":{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/3197","repository_url":"https://api.github.com/repos/marionettejs/backbone.marionette","labels_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/3197/labels{/name}","comments_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/3197/comments","events_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/3197/events","html_url":"https://github.com/marionettejs/backbone.marionette/issues/3197","id":178938074,"number":3197,"title":"Add a one-time event between attach and dom:refresh","user":{"login":"bazineta","id":564060,"avatar_url":"https://avatars.githubusercontent.com/u/564060?v=3","gravatar_id":"","url":"https://api.github.com/users/bazineta","html_url":"https://github.com/bazineta","followers_url":"https://api.github.com/users/bazineta/followers","following_url":"https://api.github.com/users/bazineta/following{/other_user}","gists_url":"https://api.github.com/users/bazineta/gists{/gist_id}","starred_url":"https://api.github.com/users/bazineta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bazineta/subscriptions","organizations_url":"https://api.github.com/users/bazineta/orgs","repos_url":"https://api.github.com/users/bazineta/repos","events_url":"https://api.github.com/users/bazineta/events{/privacy}","received_events_url":"https://api.github.com/users/bazineta/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/labels/discussion","name":"discussion","color":"cccccc"},{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/labels/enhancement","name":"enhancement","color":"bfd4f2"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-09-23T18:02:44Z","updated_at":"2016-09-25T14:20:17Z","closed_at":"2016-09-25T14:20:17Z","body":"### Description\r\n\r\nI have a top-level view that acts as a container for a set of subviews. In simplistic terms, there's a chart (Highcharts) and a table view as immediate children. These child views are provided with the container view's collection; each is responsible for displaying the collection in a view-specific manner.\r\n\r\nUpon completion of the startup of this view, a 'select' event is triggered on the collection, which causes the chart to select the associated data point, and the table to select the associated row.\r\n\r\nBecause some of the views in this hierarchy are dependent on being attached, e.g., the chart must be attached before the select can occur, it's important for the top-level container view to know when all of its descendants are attached, as triggering the select event on the collection must occur only after they have all attached. Some of the views dependent on being attached may be quite some way down from the container view; they're not necessarily immediate children of it.\r\n\r\nAt present, it seems the only way to accomplish this is to do so in the top-level container view's onDomRefresh, as that event will occur after all descendants are attached; the 'attach' event in the container view is too early, as it will occur _before_ the attach of its descendants.\r\n\r\nHowever, in that the dom:refresh event is not one-time as the attach event is, logic there must be wrapped in a once.\r\n\r\nI think it would be handy in general for a given view to know that anything below it is, in fact, ready to go, so to speak, and thus having a one-time event issued upon that state would be helpful, e.g.\r\n\r\n```\r\nfunction handleAttach() {\r\n    triggerMethodChildren(this, 'attach', shouldAttach);\r\n    triggerMethodOn(this, 'dom:ready', this);\r\n    triggerDOMRefresh(this);\r\n}\r\n```\r\n\r\nThe event name here is debatable; I've chosen one that illustrates the intent, i.e., 'The DOM below you is now completely ready in all respects, and any action you take at this point should be safe in terms of your descendants' DOM requirements.'\r\n\r\n### Environment\r\n\r\n1. Marionette version: 3.1-pre\r\n2. Backbone version: 1.3.3\r\n3. Additional build tools, etc: So, so many....\r\n"}}
{"actor":{"display_login":"bazineta"}}