Is there a way to update options dynamically?
I want to update the options of sortable element dynamically. I just don't understand how can I access the existing instance of sortable element. Let's say I created this new sortable instance. Then how can I access it and pass new options for "group > put"?
Sortable.create(requests, {
group: {
name: 'requests',
put: (['standBy', 'rooms']).concat(roomCards)
},
animation: 250
});
I'm also having a similar issue, but in my case I want to disable the sortable control dynamically which does not work (the initial disabled value is always in effect). Would someone mind answering? @RubaXa?
As an option try to use Object.assign in order to update object of options. It is working for me
Sortable options can be changed by calling the option method : this.sortable.option('disabled', false)
Any solution for that please?
@asmaLouahdi The option method
Unfortunately .option('disabled', true) won't work dynamically
Can this code work for you?
const dynamicOptions = (disabled) => {
return {
group: 'group',
disabled
//...rest options
}
}
Sortable.create(requests, dynamicOptions(true))
Sortable.create(requests2, dynamicOptions(false))
I had the same problem with an dynamic list.
Solved adding "filter: '.disabled'," to default options and toggling the class at the handle.