{"action":"created","issue":{"url":"https://api.github.com/repos/jshjohnson/Choices/issues/50","repository_url":"https://api.github.com/repos/jshjohnson/Choices","labels_url":"https://api.github.com/repos/jshjohnson/Choices/issues/50/labels{/name}","comments_url":"https://api.github.com/repos/jshjohnson/Choices/issues/50/comments","events_url":"https://api.github.com/repos/jshjohnson/Choices/issues/50/events","html_url":"https://github.com/jshjohnson/Choices/pull/50","id":182001331,"number":50,"title":"Groups handling","user":{"login":"froggiefab","id":5774943,"avatar_url":"https://avatars.githubusercontent.com/u/5774943?v=3","gravatar_id":"","url":"https://api.github.com/users/froggiefab","html_url":"https://github.com/froggiefab","followers_url":"https://api.github.com/users/froggiefab/followers","following_url":"https://api.github.com/users/froggiefab/following{/other_user}","gists_url":"https://api.github.com/users/froggiefab/gists{/gist_id}","starred_url":"https://api.github.com/users/froggiefab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/froggiefab/subscriptions","organizations_url":"https://api.github.com/users/froggiefab/orgs","repos_url":"https://api.github.com/users/froggiefab/repos","events_url":"https://api.github.com/users/froggiefab/events{/privacy}","received_events_url":"https://api.github.com/users/froggiefab/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-10T12:21:46Z","updated_at":"2016-10-11T14:22:20Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/jshjohnson/Choices/pulls/50","html_url":"https://github.com/jshjohnson/Choices/pull/50","diff_url":"https://github.com/jshjohnson/Choices/pull/50.diff","patch_url":"https://github.com/jshjohnson/Choices/pull/50.patch"},"body":"Hi,\r\n\r\nThis PR aims to add groups support on \"_ajaxCallback\".\r\nI also added two parameters to \"_addGroup\" defaulted to \"value\" and \"label\" to preserve customized properties names.\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/jshjohnson/Choices/issues/comments/252931288","html_url":"https://github.com/jshjohnson/Choices/pull/50#issuecomment-252931288","issue_url":"https://api.github.com/repos/jshjohnson/Choices/issues/50","id":252931288,"user":{"login":"froggiefab","id":5774943,"avatar_url":"https://avatars.githubusercontent.com/u/5774943?v=3","gravatar_id":"","url":"https://api.github.com/users/froggiefab","html_url":"https://github.com/froggiefab","followers_url":"https://api.github.com/users/froggiefab/followers","following_url":"https://api.github.com/users/froggiefab/following{/other_user}","gists_url":"https://api.github.com/users/froggiefab/gists{/gist_id}","starred_url":"https://api.github.com/users/froggiefab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/froggiefab/subscriptions","organizations_url":"https://api.github.com/users/froggiefab/orgs","repos_url":"https://api.github.com/users/froggiefab/repos","events_url":"https://api.github.com/users/froggiefab/events{/privacy}","received_events_url":"https://api.github.com/users/froggiefab/received_events","type":"User","site_admin":false},"created_at":"2016-10-11T14:22:20Z","updated_at":"2016-10-11T14:22:20Z","body":"I didn't provide one because it's not in the configuration object :)\r\n\r\nThe problem occured if the data received during an Ajax request where, for example, of this form :\r\n```json\r\n[\r\n\t{\r\n\t\t\"label\": \"France\",\r\n\t\t\"choices\": [\r\n\t\t\t{ \"libelle\": \"Paris\", \"code\": \"PAR\"},\r\n\t\t\t{ \"libelle\": \"Nantes\", \"code\": \"NTE\"},\r\n\t\t\t{ \"libelle\": \"Nice\", \"code\": \"NCE\"},\r\n\t\t\t{ \"libelle\": \"Bordeaux\", \"code\": \"BOD\"}\r\n\t\t]\r\n\t}\r\n]\r\n```\r\nThe callback passed when running \"ajax\" method :\r\n```javascript\r\nformControl.multiselect.ajax((callback) => {\r\n     ...\r\n     if (request.readyState === 4) {\r\n          status = request.status;\r\n               if (status === 200) {\r\n                    data = JSON.parse(request.responseText);\r\n                    callback(data, 'code', 'libelle', true);\r\n               }\r\n     }\r\n     request.send();\r\n     ...\r\n});\r\n```\r\nThe callback was only able to create choices so I added a \"_addGroup\" call.\r\nBut the  \"_addGroup\" method was always looking for \"value\" and \"label\" properties, ignoring the attributes 'code' and 'libelle' passed to the callback so I added necessary parameters.\r\n"}}
{"actor":{"display_login":"froggiefab"}}