selecto icon indicating copy to clipboard operation
selecto copied to clipboard

Reset Currently Selected Items

Open RichPitul opened this issue 2 years ago • 5 comments

Is there any way to clear the selected items programatically?

RichPitul avatar Nov 09 '22 20:11 RichPitul

As a workaround; before replacing the parent element; of which some group of its children might be selected; I set it to undefined. Then at the next tick I add them in; this accomplishes the goal of resetting what elements are selected. this.workingSection = undefined; this.$nextTick(() => { this.workingSection = section; })

RichPitul avatar Nov 10 '22 19:11 RichPitul

@RichPitul

https://daybrush.com/selecto/release/latest/doc/Selecto.html#setSelectedTargets

Use setSelectedTargets method. (result: added, removed, beforeSelected, selected) However, the selectStart, select, and selectEnd events do not occur.

daybrush avatar Nov 13 '22 12:11 daybrush

Hi. That works to change what can be selected but not to reset the selected items.

On Sun, Nov 13, 2022, 7:39 a.m. Daybrush (Younkue Choi) < @.***> wrote:

@RichPitul https://github.com/RichPitul

https://daybrush.com/selecto/release/latest/doc/Selecto.html#setSelectedTargets

Use setSelectedTargets method. (result: added, removed, beforeSelected, selected) However, the selectStart, select, and selectEnd events do not occur.

— Reply to this email directly, view it on GitHub https://github.com/daybrush/selecto/issues/109#issuecomment-1312721355, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFN5PPSIZFHMXPLNOWOTMGDWIDOPFANCNFSM6AAAAAAR3277NQ . You are receiving this because you were mentioned.Message ID: @.***>

RichPitul avatar Nov 13 '22 16:11 RichPitul

@RichPitul

Can you do this?

.setSelectedTargets([])

daybrush avatar Nov 13 '22 19:11 daybrush

Hi @daybrush, I am also looking for something similar.

I tried to call .setSelectedTargets([]) with Empty Array. I got an object in return showing that it was removed, but the method didn't trigger Select Method. I have written to empty the Moveable target in the Select Callback.

objSelectoRef
  .on("select", function (event) {
      me.targets = event.selected;
      me.objMoveable.target = me.targets;
  
      //me.objMoveable.dragTarget = me.$el.find(".dragHandle")[0];
      console.log("Active Selected Elements", me.targets.length);
  });

Should I just make moveable.target empty myself or the library can take care of it?

What is the best way to clear selected targets?

jadiagaurang avatar Jul 11 '23 19:07 jadiagaurang