Sortable icon indicating copy to clipboard operation
Sortable copied to clipboard

Is there a way to update options dynamically?

Open SZharkov opened this issue 9 years ago • 8 comments

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 });

SZharkov avatar Jun 20 '17 13:06 SZharkov

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?

nero120 avatar Jan 07 '18 21:01 nero120

As an option try to use Object.assign in order to update object of options. It is working for me

gelevanog avatar Mar 05 '18 07:03 gelevanog

Sortable options can be changed by calling the option method : this.sortable.option('disabled', false)

isabelleaubron avatar Sep 10 '18 09:09 isabelleaubron

Any solution for that please?

asmaLouahdi avatar Jun 03 '19 11:06 asmaLouahdi

@asmaLouahdi The option method

owen-m1 avatar Jun 14 '19 13:06 owen-m1

Unfortunately .option('disabled', true) won't work dynamically

cugb-xieyu avatar Jun 28 '19 02:06 cugb-xieyu

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))

gelevanog avatar Jun 28 '19 03:06 gelevanog

I had the same problem with an dynamic list.

Solved adding "filter: '.disabled'," to default options and toggling the class at the handle.

jesseqroz avatar Jul 21 '20 19:07 jesseqroz