Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Support for AJAX-loaded options? #27

Open
binary-koan opened this issue Jun 23, 2017 · 3 comments
Open

Support for AJAX-loaded options? #27

binary-koan opened this issue Jun 23, 2017 · 3 comments

Comments

@binary-koan
Copy link

I don't particularly want a full-blown lazy loading framework like select2 and friends (that would be unnecessary bloat IMO), but I'd still like some way of feeding async data into a selectr box.

My idea would be to add

  • removeOption / removeAllOptions methods to go alongside addOption
  • A search event triggered when anything is typed into the search box

Then I could have something along the lines of

var selectr = new Selectr("#my-lazy-select")

selectr.on("selectr.search", query => {
  if (query.length >= 3) {
    fetch("/results.json", { body: { query } }).then(results => {
      selectr.removeAllOptions()
      results.forEach(result => selectr.addOption(result))
    })
  }
})

... or something totally different (for example, with this approach having a loading spinner would be kinda annoying).

Let me know what you think :)

@Mobius1
Copy link
Owner

Mobius1 commented Jun 23, 2017

This is something I've mulling over for a while so it's probably time to implement it. I'll give it some time over the weekend.

@klaudiomilankovic
Copy link

Hi @Mobius1 , is this something currently working? Our team is considering using this in a project, but we need ajax support.

@Mobius1
Copy link
Owner

Mobius1 commented Oct 4, 2018

It's currently on track, but no ETA yet. I've had to abandon some other repos to concentrate on this one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants