Mobius1/Selectr

Destroy the instance and recreate one

Closed this issue · 2 comments

I am coding a wrapper of this great library for React. I was wondering if there is a way to destroy an instance and re-initialize it with new settings. (I saw reset, but it reset it to the original. I need to make a new one with different options)

You can pass your new settings to the render() method after destroying.

// instantiate
const instance = new Selectr("#mySelect", oldConfig);

// destroy
instance.destroy()

// render with new config
instance.render(newConfig)

@Mobius1 great, thank you!