{"action":"closed","issue":{"url":"https://api.github.com/repos/chmln/flatpickr/issues/229","repository_url":"https://api.github.com/repos/chmln/flatpickr","labels_url":"https://api.github.com/repos/chmln/flatpickr/issues/229/labels{/name}","comments_url":"https://api.github.com/repos/chmln/flatpickr/issues/229/comments","events_url":"https://api.github.com/repos/chmln/flatpickr/issues/229/events","html_url":"https://github.com/chmln/flatpickr/issues/229","id":169615117,"number":229,"title":"Clearing programmatically?","user":{"login":"mgibbs189","id":115410,"avatar_url":"https://avatars.githubusercontent.com/u/115410?v=3","gravatar_id":"","url":"https://api.github.com/users/mgibbs189","html_url":"https://github.com/mgibbs189","followers_url":"https://api.github.com/users/mgibbs189/followers","following_url":"https://api.github.com/users/mgibbs189/following{/other_user}","gists_url":"https://api.github.com/users/mgibbs189/gists{/gist_id}","starred_url":"https://api.github.com/users/mgibbs189/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgibbs189/subscriptions","organizations_url":"https://api.github.com/users/mgibbs189/orgs","repos_url":"https://api.github.com/users/mgibbs189/repos","events_url":"https://api.github.com/users/mgibbs189/events{/privacy}","received_events_url":"https://api.github.com/users/mgibbs189/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-05T14:06:40Z","updated_at":"2016-08-07T03:16:06Z","closed_at":"2016-08-07T03:16:06Z","body":"Hey @chmln \r\n\r\nPreviously, I asked about adding a `Clear` button into the flatpickr popup itself.\r\n\r\n<img src=\"http://i.imgur.com/x2Tq2Xi.png\" width=\"208\" height=\"267\" />\r\n\r\nI got it working with the following code, but I'm not sure if this is the best approach. Do you have any feedback or suggestions?\r\n\r\n```js\r\nvar flatpickr_opts = {\r\n    altInput: true,\r\n    altInputClass: 'flatpickr-alt',\r\n    altFormat: 'F j, Y',\r\n    onReady: function(dateObj, dateStr, instance) {\r\n        $('.flatpickr-calendar').each(function() {\r\n            var $this = $(this);\r\n            if ($this.find('.flatpickr-clear').length < 1) {\r\n                $this.append('<div class=\"flatpickr-clear\">Clear</div>');\r\n                $this.find('.flatpickr-clear').on('click', function() {\r\n                    instance.clear();\r\n                    instance.close();\r\n                });\r\n            }\r\n        });\r\n    }\r\n};\r\n```"}}
{"actor":{"display_login":"chmln"}}