Skip to content

Instantly share code, notes, and snippets.

View ests's full-sized avatar

Ernest ests

  • IesT
  • EU
View GitHub Profile

Plan

  1. Create a Stimulus controller for table filtering
  2. Add filter form elements to your view
  3. Update your controller to handle filter parameters
  4. Use Turbo Streams to update the table content
  5. Preserve existing datatable functionality

Implementation

Based on the documentation I've reviewed, I can provide you with a comprehensive answer about Stimulus.js and its suitability for working with JSON vs HTML partials in Rails applications.

Stimulus.js Philosophy: HTML-First Approach

Stimulus.js is designed around the "HTML-first" philosophy, which aligns perfectly with the traditional Rails way. Here's what this means for your JSON vs HTML partials question:

HTML Partials (The Rails Way) - Recommended

Stimulus.js works exceptionally well with HTML partials and server-rendered content: