Skip to content
This repository has been archived by the owner on May 25, 2018. It is now read-only.

Stop results updating items when no longer valid #272

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Typeahead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ const typeahead = {
},
methods: {
update() {
// store initial query
var originalQuery = this.query;
if (!this.query) {
this.reset()
return false
Expand All @@ -117,8 +119,12 @@ const typeahead = {
}
if (this.async) {
callAjax(this.async + this.query, (data)=> {
this.items = (this.key ? data[this.key] : data).slice(0, this.limit)
this.showDropdown = this.items.length ? true : false
//when the results come back check if they are still required by checking origianl query agains current query
if(originalQuery == this.query){
// only update items with request data if the query has not changed and is still valid
this.items = (this.key ? data[this.key] : data).slice(0, this.limit)
this.showDropdown = this.items.length ? true : false
}
})
}
},
Expand Down