Choices icon indicating copy to clipboard operation
Choices copied to clipboard

How to change the transmitted parameter?

Open uCryNet opened this issue 6 years ago • 2 comments

Suppose I initialize a library with parameters:

  const instances = multipleSelect.map((element) => {
    let init = new Choices(element, {
      searchEnabled: true,
      itemSelectText: '',
      removeItemButton: true,
      shouldSort: true,
      noChoicesText: 'None'
    })
  })

How can I change parameters during an event change, for example, from searchEnabled: true to searchEnabled: false or add a new/delete parameter.

I run it:

  const instances = multipleSelect.map((element) => {
    let init = new Choices(element, {
      searchEnabled: true,
      itemSelectText: '',
      removeItemButton: true,
      shouldSort: true,
      noChoicesText: 'None',
    })

    element.addEventListener('change', (event) => {
      // here I want to change from "searchEnabled: true" to "searchEnabled: false"
    })
  })

That is, I want the parameters to change during the event

uCryNet avatar Nov 14 '19 14:11 uCryNet

So? Anyone have solution or variant how this done? I want to dynamically change some config options like removeItemButton, searchPlaceholderValue, but can't see where I can do that((

Woloja avatar Apr 20 '21 12:04 Woloja

So? Anyone have solution or variant how this done? I want to dynamically change some config options like removeItemButton, searchPlaceholderValue, but can't see where I can do that((

there is no convenient solution. You need to store instances of the selects you want to change. And kill it with destroy(), and then re-initialize it with the required parameters

uCryNet avatar May 04 '21 12:05 uCryNet