Choices: Problem with ajax search

Created on 13 Dec 2018  路  2Comments  路  Source: Choices-js/Choices

Problem with ajax search. I am added listener search and run function ajax get data by search item.
In time of running function: dropped focus and disable input. Its problem, how to fix ?

var myHeaders = new Headers() this.choices_example.passedElement.element.addEventListener('search', (event) => { if (event.detail.value.length > 2) { const formData = new FormData() formData.append('find', event.detail.value) this.choices_example.ajax(function (callback) { fetch('some-url', { method: 'POST', headers: myHeaders, cache: 'default', body: formData }).then(function (response) { response.json().then(function (data) { console.log(data) callback(data, 'key', 'value') }) }).catch(function (error) { console.error(error) }) }) } })

Most helpful comment

@shmidtelson considering similar, can you provide more detail or code example of how/where you used setChoices to resolve your problem?

All 2 comments

setChoices() fixed my problem

@shmidtelson considering similar, can you provide more detail or code example of how/where you used setChoices to resolve your problem?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ckotzbauer picture ckotzbauer  路  5Comments

stephendolan picture stephendolan  路  3Comments

notflip picture notflip  路  3Comments

NetanelBasal picture NetanelBasal  路  5Comments

mpreziuso picture mpreziuso  路  3Comments