Bulk Operation
In this guide, I will show you how to Bulk Operation
with Hotwire.
How it Works
- We can build a Stimulus controller to handle the click event of the button for
Bulk Operation
- The Stimulus controller will collect the
id
of the selected items, and then send data to the server using nativefetch
or 3-party js lib such asaxios
- The server can process request according to the
id
, and returnTurbo Stream
to update the page item details. - Once Stimulus controller receive the response, use
Turbo.renderStreamMessage(streamActionHTML)
to process the HTML which contains Turbo Stream code.
To make Select All
work, you can also use this Stimulus Controller Stimulus Checkbox Select All