{"action":"created","issue":{"url":"https://api.github.com/repos/algolia/instantsearch.js/issues/66","labels_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/66/labels{/name}","comments_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/66/comments","events_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/66/events","html_url":"https://github.com/algolia/instantsearch.js/pull/66","id":105236893,"number":66,"title":"feat: Switch/Toggle widget","user":{"login":"pixelastic","id":283419,"avatar_url":"https://avatars.githubusercontent.com/u/283419?v=3","gravatar_id":"","url":"https://api.github.com/users/pixelastic","html_url":"https://github.com/pixelastic","followers_url":"https://api.github.com/users/pixelastic/followers","following_url":"https://api.github.com/users/pixelastic/following{/other_user}","gists_url":"https://api.github.com/users/pixelastic/gists{/gist_id}","starred_url":"https://api.github.com/users/pixelastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pixelastic/subscriptions","organizations_url":"https://api.github.com/users/pixelastic/orgs","repos_url":"https://api.github.com/users/pixelastic/repos","events_url":"https://api.github.com/users/pixelastic/events{/privacy}","received_events_url":"https://api.github.com/users/pixelastic/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/algolia/instantsearch.js/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-09-07T15:32:06Z","updated_at":"2015-09-08T08:02:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/algolia/instantsearch.js/pulls/66","html_url":"https://github.com/algolia/instantsearch.js/pull/66","diff_url":"https://github.com/algolia/instantsearch.js/pull/66.diff","patch_url":"https://github.com/algolia/instantsearch.js/pull/66.patch"},"body":"Here is the switch/toggle widget that adds a boolean conjunctive filter and removes it with a checkbox.\r\n\r\nUse case is hiding/showing all results that have for example `free_shipping: true`. When checked, only items with this attribute `true` will be displayed. When unchecked, all items will be displayed.\r\n\r\nI renamed it from `switch` to `toggle` because naming variables `switch` in JavaScript caused issues as this is a reserved keyword.\r\n\r\nComments welcome"},"comment":{"url":"https://api.github.com/repos/algolia/instantsearch.js/issues/comments/138468160","html_url":"https://github.com/algolia/instantsearch.js/pull/66#issuecomment-138468160","issue_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/66","id":138468160,"user":{"login":"pixelastic","id":283419,"avatar_url":"https://avatars.githubusercontent.com/u/283419?v=3","gravatar_id":"","url":"https://api.github.com/users/pixelastic","html_url":"https://github.com/pixelastic","followers_url":"https://api.github.com/users/pixelastic/followers","following_url":"https://api.github.com/users/pixelastic/following{/other_user}","gists_url":"https://api.github.com/users/pixelastic/gists{/gist_id}","starred_url":"https://api.github.com/users/pixelastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pixelastic/subscriptions","organizations_url":"https://api.github.com/users/pixelastic/orgs","repos_url":"https://api.github.com/users/pixelastic/repos","events_url":"https://api.github.com/users/pixelastic/events{/privacy}","received_events_url":"https://api.github.com/users/pixelastic/received_events","type":"User","site_admin":false},"created_at":"2015-09-08T08:02:38Z","updated_at":"2015-09-08T08:02:38Z","body":"The code we have on the refinementList for catching the event is quite complex IMHO, and we only needed it because we provided the user the ability to add a custom template. As I'm not doing it here, just listening to the checkbox change event is enough.\r\n\r\nThe thing is, the way we will handle event is tightly linked to if and how we handle the templates. If we do not let the user change the template and provide our own HTML markup, then we can listen to specific event on our own markup (like the change event on the `checkbox`).\r\n\r\nIf we let the user completely change the template, then it may or may not use a checkbox (which will in that case become only a design element and not part of the widget behavior). In that case, we'll have to listen to our events higher in the hierarchy (`click` event on the wrapper instead of `change` event on the checkbox). And as we've seen, this comes with its own strange bugs (`click` event firing twice when wrapping checkbox in label).\r\n\r\nSo, to conclude, I think putting the onclick on top would be the way to go if we go the template route. But as we're still ensure how to handle template, I'll just put that on hold for now :)"}}