selecto
selecto copied to clipboard
Reset Currently Selected Items
Is there any way to clear the selected items programatically?
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
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.
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
Can you do this?
.setSelectedTargets([])
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?