search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

How can I make item not draggable

Asked by Naomi
4 years ago.

Hi,

I'm using the following code:

rowClick(booking, index) {
            if (this.selectedRow === index) {
                this.selectedRow = -1;
            }
            else {
                this.selectedRow = index;
                const drag = document.getElementById(`clipboardBooking${index}`);
                if (drag) {
                    drag.style.cursor = "move";
                    DayPilot.Scheduler.makeDraggable({
                        element: drag,
                        id: booking.id,
                        duration: booking.duration,
                        keepElement: true,
                        text: booking.text,
                        data: booking,
                        externalHtml: booking.text
                    });
                }

                if (this.onBookingSelected) {
                    this.onBookingSelected({ currentBooking: booking });
                }
            }
        }

E.g. I want to first click on my row in the clipboard, perform some action and make that item draggable. All other items needs to be not draggabble and also if I click again I want to "unclick" that row.

So my question is - once I made my item draggable, how can I make it "normal" again? I guess I can change the style of the cursor, but would it be enough?

Thanks in advance.

Answer posted by Naomi
4 years ago.

Never mind, solved it with the following:

for (let i = 0; i < this.bookings.length; i++) {
                const drag = document.getElementById(`clipboardBooking${i}`);
                if (drag) {
                    drag.setAttribute("draggable", false);
                    drag.style.cursor = "pointer";
                }
            }
Comment posted by Naomi
4 years ago.

I do have the other question, though. Can you add a sample of the options.onDragStart implementation? It would not interfere with the eventMove, right?

I want to reset this.selectedRow = -1; in that event.

Comment posted by Naomi
4 years ago.

Never mind, solved this too.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.