Drag and Drop Sortable Lists in Ruby on Rails

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Why on `Rails.ajax({...})` am I getting ReferenceError: Rails is not defined?

SouravTechLabs
Автор

I’m loving the episodes where you use Stimulus. I think is SO important for someone to demystify it and I’m glad you’re doing it. Keep ‘em coming man! They’re amazing!

julianpinzoneslava
Автор

Thanks for the tutorial Chris, it's great. But I think this implementation will fail for all but trivial scenarios. Assigning position value to an item based on its position in the list will work for the newly created untouched list but let's say I have a list of 15 todos. I've completed most of them and left with tasks 5 (first), 10 (second), 15 (third). Now, when I move task 5 to the bottom of the list it will be assigned with the position of 3 since it's third now. But tasks 10 and 15 have corresponding position values and will stay in the second and third positions. The only way to move task 5 to the third position in the list is to move tasks 10 and 15 up so that they are assigned with positions 1 and 2. There are other issues but it's a simple one. It will also fail when different users manage their to-do lists, they will be overriding each other's tasks positions. I still think it's a great tutorial overall, just wanted to warn anyone who'd like to implement it in production.

inmydelorean
Автор

Awesome video Chris. Since: Rails.ajax ({
url: this.data.get("url").replace(":id", id),
type: 'PATCH',
data: data
}) Depends on, @rails/ujs, This other option works for me without importing, @rails/ujs. ----> end(event) {
const id = event.item.dataset.id;
const data = new FormData();
data.append("position", event.newIndex + 1);

fetch(this.data.get("url").replace(":id", id), {
method: 'PATCH',
headers: {
'X-CSRF-Token': document.getElementsByName('csrf-token')[0].content,
'Content-Type': 'application/json',
},
body: JSON.stringify(Object.fromEntries(data)),
});
}

ellyambet
Автор

There is any way to do the same with react and material UI? @GoRails

ShadabAli-gseo
Автор

Where is the nested sortable episode ?

dp
Автор

I'm a newbie in ruby on rails. I have two controllers for the same model in index page of both of these controllers we can reorder. I want different ordering systems in both. Meaning postion for one controller and maybe other_position for the other controller. Is this possible?

bhaktikulkarni
Автор

Do you have any suggestions for a sortable card-grid. SortableJS has a grid example on their page, but I can't find any documentation to see how they achieved that. I am using CSS-Grids to create a responsive card grid, but when I add the data-controller, my grid is rendered as a list. I am not seeing anything in the inspector to indicate what is happening.

josephcaughlin
Автор

Hello rails newbie here.
Which do you think would be better to use between jquery-ui sortable and this?

vncntc
Автор

but why stimulus? can't we just use plain javascript for it?

YaroslavShmarov
Автор

Where are the classes like mb-4 defined that I see you using regularly?

BrazenNL
Автор

Everything when fine on my side until I have the following error messge (ruby on rails console):

(Can't verify CSRF token authenticity.):

yanikcrepeau