{"action":"created","issue":{"url":"https://api.github.com/repos/devbridge/jQuery-Autocomplete/issues/438","labels_url":"https://api.github.com/repos/devbridge/jQuery-Autocomplete/issues/438/labels{/name}","comments_url":"https://api.github.com/repos/devbridge/jQuery-Autocomplete/issues/438/comments","events_url":"https://api.github.com/repos/devbridge/jQuery-Autocomplete/issues/438/events","html_url":"https://github.com/devbridge/jQuery-Autocomplete/issues/438","id":116989358,"number":438,"title":"onInvalidateSelection only works after selection","user":{"login":"ruskid","id":8279841,"avatar_url":"https://avatars.githubusercontent.com/u/8279841?v=3","gravatar_id":"","url":"https://api.github.com/users/ruskid","html_url":"https://github.com/ruskid","followers_url":"https://api.github.com/users/ruskid/followers","following_url":"https://api.github.com/users/ruskid/following{/other_user}","gists_url":"https://api.github.com/users/ruskid/gists{/gist_id}","starred_url":"https://api.github.com/users/ruskid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruskid/subscriptions","organizations_url":"https://api.github.com/users/ruskid/orgs","repos_url":"https://api.github.com/users/ruskid/repos","events_url":"https://api.github.com/users/ruskid/events{/privacy}","received_events_url":"https://api.github.com/users/ruskid/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-15T11:59:30Z","updated_at":"2015-11-15T12:11:56Z","closed_at":null,"body":"Hi, thanks for the work!\r\nonInvalidateSelection only works if the item was selected by the user.\r\n\r\nI got a situation where I preload some values into autocomplete input and hidden input on page load. So in this case if user will change autocomplete input then the hidden will remain the same, because nothing was selected previously.\r\n\r\nImagine update situation where you preload user's values.\r\n"},"comment":{"url":"https://api.github.com/repos/devbridge/jQuery-Autocomplete/issues/comments/156807610","html_url":"https://github.com/devbridge/jQuery-Autocomplete/issues/438#issuecomment-156807610","issue_url":"https://api.github.com/repos/devbridge/jQuery-Autocomplete/issues/438","id":156807610,"user":{"login":"ruskid","id":8279841,"avatar_url":"https://avatars.githubusercontent.com/u/8279841?v=3","gravatar_id":"","url":"https://api.github.com/users/ruskid","html_url":"https://github.com/ruskid","followers_url":"https://api.github.com/users/ruskid/followers","following_url":"https://api.github.com/users/ruskid/following{/other_user}","gists_url":"https://api.github.com/users/ruskid/gists{/gist_id}","starred_url":"https://api.github.com/users/ruskid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruskid/subscriptions","organizations_url":"https://api.github.com/users/ruskid/orgs","repos_url":"https://api.github.com/users/ruskid/repos","events_url":"https://api.github.com/users/ruskid/events{/privacy}","received_events_url":"https://api.github.com/users/ruskid/received_events","type":"User","site_admin":false},"created_at":"2015-11-15T12:11:56Z","updated_at":"2015-11-15T12:11:56Z","body":"```js\r\nonValueChange: function () {\r\n            var that = this,\r\n                options = that.options,\r\n                value = that.el.val(),\r\n                query = that.getQuery(value);\r\n\r\n            if (that.selection && that.currentValue !== query) {\r\n                that.selection = null;\r\n                (options.onInvalidateSelection || $.noop).call(that.element);\r\n            }\r\n}\r\n```\r\nthat.selection is mandatory. As a quick fix a changed it to \"that.selection || that.currentValue !== query\"\r\nLet me know if its wrong.\r\n"}}