{"action":"created","issue":{"url":"https://api.github.com/repos/hmrc/assets-frontend/issues/493","repository_url":"https://api.github.com/repos/hmrc/assets-frontend","labels_url":"https://api.github.com/repos/hmrc/assets-frontend/issues/493/labels{/name}","comments_url":"https://api.github.com/repos/hmrc/assets-frontend/issues/493/comments","events_url":"https://api.github.com/repos/hmrc/assets-frontend/issues/493/events","html_url":"https://github.com/hmrc/assets-frontend/issues/493","id":143294418,"number":493,"title":"toggleDynamicFormFields Javascript issue","user":{"login":"Muhammad-Ali-Ahmad","id":17907161,"avatar_url":"https://avatars.githubusercontent.com/u/17907161?v=3","gravatar_id":"","url":"https://api.github.com/users/Muhammad-Ali-Ahmad","html_url":"https://github.com/Muhammad-Ali-Ahmad","followers_url":"https://api.github.com/users/Muhammad-Ali-Ahmad/followers","following_url":"https://api.github.com/users/Muhammad-Ali-Ahmad/following{/other_user}","gists_url":"https://api.github.com/users/Muhammad-Ali-Ahmad/gists{/gist_id}","starred_url":"https://api.github.com/users/Muhammad-Ali-Ahmad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Muhammad-Ali-Ahmad/subscriptions","organizations_url":"https://api.github.com/users/Muhammad-Ali-Ahmad/orgs","repos_url":"https://api.github.com/users/Muhammad-Ali-Ahmad/repos","events_url":"https://api.github.com/users/Muhammad-Ali-Ahmad/events{/privacy}","received_events_url":"https://api.github.com/users/Muhammad-Ali-Ahmad/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-24T16:29:46Z","updated_at":"2016-03-25T08:43:08Z","closed_at":null,"body":"## Issue Description \r\nI am using toggleDynamicFormFields Javascript to show/hide 3 check boxes based on a radio button. Upon checking each of the check box, additional content is displayed. \r\n\r\nThe Javascript doesn't work correctly for the 3 check boxes if the page is reloaded with pre-submitted data. If some data is submitted then ideally on page load content should be displayed, relevant checked boxes checked and radio button selected to show. This is the case when user submits with errors on the page and if user goes to next page and comes back to the current page.\r\n\r\nSecond issue is that after showing the fields, if the user selects \"No\" radio button then the state should reset in sense that the fields should be emptied, collapsed, check boxes unchecked and hidden so after clicking yes the whole process begins starts again.\r\nCurrently this is not the case. Upon selecting \"No\" the fields are not collapsed and check boxes not unchecked. This breaks the functionality of the page.\r\n\r\n## Basic markup structure:\r\n\r\n```\r\n<!DOCTYPE html>\r\n<body>\r\n<fieldset>\r\n   <label>\r\n       Yes\r\n       <input type=\"radio\" data-dynamic-fields-hide=\"false\">\r\n   </label>\r\n   <label>\r\n       No \r\n       <input type=\"radio\" data-dynamic-fields-hide=\"true\">\r\n   </label>\r\n\r\n   <div>\r\n      <div>\r\n         <label>\r\n            <span>Employment</span>\r\n            <input type=\"checkbox\" data-dynamic-fields-hide=\"false\">\r\n         </label>\r\n         <div>\r\n            <div>\r\n               <label>\r\n                    <span>\r\n                        What will your income be?\r\n                    </span>\r\n               </label>\r\n               <input type=\"text\" value=\"\">\r\n            </div>\r\n         </div>\r\n      </div>\r\n      <div>\r\n         <label>\r\n            <span>Other income</span>\r\n            <input type=\"checkbox\" data-dynamic-fields-hide=\"false\">\r\n         </label>\r\n         <div>\r\n            <div>\r\n               <label>\r\n                    <span>\r\n                        What will your income be?\r\n                    </span>\r\n               </label>\r\n               <input type=\"text\" value=\"\">\r\n            </div>\r\n         </div>\r\n      </div>\r\n      <div>\r\n         <label>\r\n            <span>Benefits</span>\r\n            <input type=\"checkbox\" data-dynamic-fields-hide=\"false\">\r\n         </label>\r\n         <div>\r\n            <div>\r\n               <label>\r\n                    <span>\r\n                        What will your income be?\r\n                    </span>\r\n               </label>\r\n               <input type=\"text\" value=\"\">\r\n            </div>\r\n         </div>\r\n      </div>\r\n   </div>\r\n</fieldset>\r\n</body>\r\n```\r\n\r\n## How the page should work - Gif 1: \r\n![income1](https://cloud.githubusercontent.com/assets/17907161/14024225/276a0f8c-f1e0-11e5-913a-651fd1f1027a.gif)\r\n\r\n## How the page should work - Gif 2: \r\n![income2](https://cloud.githubusercontent.com/assets/17907161/14024231/2c78fc22-f1e0-11e5-9a96-5ce4fa51ffb1.gif)\r\n\r\n## How the page should work - Gif 3: \r\n![income3](https://cloud.githubusercontent.com/assets/17907161/14024236/311ae614-f1e0-11e5-9936-63936d828fce.gif)\r\n"},"comment":{"url":"https://api.github.com/repos/hmrc/assets-frontend/issues/comments/201203609","html_url":"https://github.com/hmrc/assets-frontend/issues/493#issuecomment-201203609","issue_url":"https://api.github.com/repos/hmrc/assets-frontend/issues/493","id":201203609,"user":{"login":"feedmypixel","id":2305016,"avatar_url":"https://avatars.githubusercontent.com/u/2305016?v=3","gravatar_id":"","url":"https://api.github.com/users/feedmypixel","html_url":"https://github.com/feedmypixel","followers_url":"https://api.github.com/users/feedmypixel/followers","following_url":"https://api.github.com/users/feedmypixel/following{/other_user}","gists_url":"https://api.github.com/users/feedmypixel/gists{/gist_id}","starred_url":"https://api.github.com/users/feedmypixel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feedmypixel/subscriptions","organizations_url":"https://api.github.com/users/feedmypixel/orgs","repos_url":"https://api.github.com/users/feedmypixel/repos","events_url":"https://api.github.com/users/feedmypixel/events{/privacy}","received_events_url":"https://api.github.com/users/feedmypixel/received_events","type":"User","site_admin":false},"created_at":"2016-03-25T08:43:07Z","updated_at":"2016-03-25T08:43:07Z","body":"Issue is related to this https://github.com/hmrc/assets-frontend/issues/475 whcih is concerned with a tidy up in this file."}}