{"action":"closed","issue":{"url":"https://api.github.com/repos/iainc/iA-Writer-Templates/issues/17","repository_url":"https://api.github.com/repos/iainc/iA-Writer-Templates","labels_url":"https://api.github.com/repos/iainc/iA-Writer-Templates/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/iainc/iA-Writer-Templates/issues/17/comments","events_url":"https://api.github.com/repos/iainc/iA-Writer-Templates/issues/17/events","html_url":"https://github.com/iainc/iA-Writer-Templates/issues/17","id":197614042,"number":17,"title":"Event after iA Writer Populates data attributes","user":{"login":"cpimhoff","id":8321370,"avatar_url":"https://avatars.githubusercontent.com/u/8321370?v=3","gravatar_id":"","url":"https://api.github.com/users/cpimhoff","html_url":"https://github.com/cpimhoff","followers_url":"https://api.github.com/users/cpimhoff/followers","following_url":"https://api.github.com/users/cpimhoff/following{/other_user}","gists_url":"https://api.github.com/users/cpimhoff/gists{/gist_id}","starred_url":"https://api.github.com/users/cpimhoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpimhoff/subscriptions","organizations_url":"https://api.github.com/users/cpimhoff/orgs","repos_url":"https://api.github.com/users/cpimhoff/repos","events_url":"https://api.github.com/users/cpimhoff/events{/privacy}","received_events_url":"https://api.github.com/users/cpimhoff/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-26T19:25:43Z","updated_at":"2016-12-27T02:46:47Z","closed_at":"2016-12-27T02:46:46Z","body":"It is difficult to edit the DOM on a document using Javascript because there is no Javascript event that iA Writer sends after it has completed replacing the `data-document` attribute with content.\r\n\r\nFor example, a user wants to have their template change the contents of all the 'h1' tags. The following snippet will not work, because the iteration through all the documents tags will be empty, they have yet to be populated by iA Writer by the time the window loads.\r\n\r\n```javascript\r\nwindow.addEventListener('load',function() {\r\n    var headings = document.getElementsByTagName(\"h1\");\r\n    for(var i = 0; i < headings.length; i++){\r\n        headings[i].innerHTML = 'changed!';\r\n    }\r\n});\r\n```\r\n\r\nThe problem is then, changing the event so that the snippet runs _after_ iA Writer has populated the `data-document` tag, but it is unclear what event would satisfy that.\r\n\r\nIs there currently a workaround or better approach? If not, iA Writer should provide a hook that always runs after iA Writer has populated the data attributes."}}
{"actor":{"display_login":"antons"}}