import { Controller } from "@hotwired/stimulus"; import Sortable from 'sortablejs' export default class extends Controller { connect() { this.sortable = Sortable.create(this.element, { onEnd: this.end.bind(this) }); } end(event) { // Envoyer les nouvelles positions au serveur const data = new FormData(); data.append('oldIndex', event.oldIndex); data.append('newIndex', event.newIndex); fetch('/update-order', { method: 'POST', body: data }); } }