This repository has been merged into http://github.com/bullet-train-co/bullet_train-core.
bullet-train-co / bullet_train-sortable Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
This repository has been merged into http://github.com/bullet-train-co/bullet_train-core.
Using turbo streams, sortable does not re-initialize after a turbo update.
I'm using turbo frames and more specifically a turbo_stream.update
to re-render a list page.
As a super hack I tried catching 'turbo:frame-load' and triggering 'sprinkles:update' so that the sortable hooks run. This worked, but it was pretty gross. Moreover, there is no turbo after-stream render event (and looks like there never will be hotwired/turbo#92 ) so I can't get sortable to re-initialize then.
The reason turbo isn't going to send that event is because they want everything to move to stimulus. AFAICT that makes sense here too and everything will work if we stimul-ify https://github.com/bullet-train-co/bullet_train-sortable/blob/main/app/javascript/concerns/sortable.js
I can try to PR that in if this sounds like the right approach to you.
Steps to reproduce:
Step 1: Prepare a demo project
1.1 Start a new project from the starter repo
1.2 run bin/configure
and name application to "Sortable Demo"
1.3. run bin/setup
Step 2: Add a sortable super scaffolded resource
2.1 Create a model: rails g model Book name:string team:references sort_order:integer
2.2 Make sure Team has_many :books
2.3 Super Scaffold a Books Resource with --sortable
flag: bin/super-scaffold crud Book Team name:string --sortable
Step 3: Add books, re-order, check console, refresh the page
3.1 Run bin/dev
, create an account and from the dashboard, add books
3.2 When a few books are added, attempt a re-order by dragging books into a different order
3.3 Check the console, you should see an 422 error logged into the console
3.4 Refresh the page. The order of books should not be the same as before the refresh
To fix:
$.post()
request includes the csrf-token
meta tag content. This should be in by default across the whole project, but for some reason @rails/ujs
doesn't pick up jQuery's inclusion into the project.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.