{"action":"created","issue":{"url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/132","labels_url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/132/labels{/name}","comments_url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/132/comments","events_url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/132/events","html_url":"https://github.com/matteodem/meteor-easy-search/pull/132","id":55614133,"number":132,"title":"Added resetAutosuggest() to the Component API","user":{"login":"dustin-cooler","id":3586861,"avatar_url":"https://avatars.githubusercontent.com/u/3586861?v=3","gravatar_id":"","url":"https://api.github.com/users/dustin-cooler","html_url":"https://github.com/dustin-cooler","followers_url":"https://api.github.com/users/dustin-cooler/followers","following_url":"https://api.github.com/users/dustin-cooler/following{/other_user}","gists_url":"https://api.github.com/users/dustin-cooler/gists{/gist_id}","starred_url":"https://api.github.com/users/dustin-cooler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dustin-cooler/subscriptions","organizations_url":"https://api.github.com/users/dustin-cooler/orgs","repos_url":"https://api.github.com/users/dustin-cooler/repos","events_url":"https://api.github.com/users/dustin-cooler/events{/privacy}","received_events_url":"https://api.github.com/users/dustin-cooler/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/matteodem/meteor-easy-search/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-27T12:54:47Z","updated_at":"2015-01-27T16:43:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/matteodem/meteor-easy-search/pulls/132","html_url":"https://github.com/matteodem/meteor-easy-search/pull/132","diff_url":"https://github.com/matteodem/meteor-easy-search/pull/132.diff","patch_url":"https://github.com/matteodem/meteor-easy-search/pull/132.patch"},"body":"Thank you for your Easy Search package, it is proving very useful. However, there wasn't a way to reset the selected items in the autosuggest component, so I added one. I hope you don't mind. It does three things:\r\n\r\n* Clears the esInput field if it can find it\r\n* Clears the search results via calling the already-built-in .clear()\r\n* Clears the selected items\r\n\r\n.resetAutosuggest() accepts an optional context parameter to help it find the correct esInput field in case there's more than one autosuggest component on the page. If a context isn't provided, .resetAutosuggest() builds a selector using the component's id and index properties if they're set. To guard against edge cases, it will only clear the esInput field if jQuery finds exactly one.\r\n\r\nExample usage:\r\n\r\n```\r\n<template name=\"myForm\">\r\n  <div class=\"my-form\">\r\n    {{> esAutosuggest index=\"tags\" id=\"myFormTags\" placeholder=\"Add tags\"}}\r\n    <button class=\"cancel\">Cancel</button>\r\n  </div>\r\n</template>\r\n\r\nTemplate.myForm.events({\r\n  'click .cancel' : function (e) {\r\n    var instance = EasySearch.getComponentInstance({\r\n      'id': 'myFormTags',\r\n      'index': 'tags'\r\n    });\r\n    \r\n    var context = $(e.target).parent();\r\n    \r\n    instance.resetAutosuggest(context);\r\n  }\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/comments/71680874","html_url":"https://github.com/matteodem/meteor-easy-search/pull/132#issuecomment-71680874","issue_url":"https://api.github.com/repos/matteodem/meteor-easy-search/issues/132","id":71680874,"user":{"login":"matteodem","id":1301147,"avatar_url":"https://avatars.githubusercontent.com/u/1301147?v=3","gravatar_id":"","url":"https://api.github.com/users/matteodem","html_url":"https://github.com/matteodem","followers_url":"https://api.github.com/users/matteodem/followers","following_url":"https://api.github.com/users/matteodem/following{/other_user}","gists_url":"https://api.github.com/users/matteodem/gists{/gist_id}","starred_url":"https://api.github.com/users/matteodem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matteodem/subscriptions","organizations_url":"https://api.github.com/users/matteodem/orgs","repos_url":"https://api.github.com/users/matteodem/repos","events_url":"https://api.github.com/users/matteodem/events{/privacy}","received_events_url":"https://api.github.com/users/matteodem/received_events","type":"User","site_admin":false},"created_at":"2015-01-27T16:43:48Z","updated_at":"2015-01-27T16:43:48Z","body":"Hey dustin, thank's a lot for the implementation. I left some comments"}}