Dragula js - How to create a shareable link with items order?

74 views Asked by At

I'm using dragula js for ordering elements based on user personalization. Once the personalized order is in place I want to create a shareable link with the order so that when the page is loaded with this link, the elements are displayed in the set order. Is that possible with dragula or should I create something custom. Any insights into this would be helpful. Thanks in advance!

1

There are 1 answers

0
Zaedonn On

This is possible. My approach would be to use a url that defines the order.

  1. When an item is dropped, update your order.
  2. Use a url that has the order (in some form) in the url.

For 1, dragula has a 'drop' event, and on that event you can re-calculate your order. And for the url that has order in it, for example I would show you coolors.co. It does even have some drag and drop, but I did not check if it was dragula specifically.

Basically, you reorder, and get a new url that reflects that, and the url contains your order so when you share it, it maintains your preferred order.