brianvoe / slim-select

Slim advanced select dropdown
http://slimselectjs.com
MIT License
1.03k stars 195 forks source link

Event addable need option loading when create #509

Closed matamune94 closed 7 months ago

matamune94 commented 7 months ago

Sometimes requests from the api can take a long time to execute, I need an option to mark item creation as being done

For example I have an additional loading field from params

    new SlimSelect({
      select: "#select-idea",
      events: {
        search: _debounce((search) => handleFetchData(search), 400),
        addable: function (value, loading) {
          return new Promise((resolve) => {
            loading.value = true
            setTimeout(() => {
            loading.value = false
              resolve(value)
            }, 3000)
          })
        },
      },
    })

If loading is true, the create button will change to a rotating icon, or maybe we can customize this icon ourselves.

brianvoe commented 7 months ago

ok