I wish there were an “any” event so we could write
data-action="*->line#some_action"
instead of
data-action="focus->line#on_focus blur->line#on_blur keyup->line#on_keyup ...."
Would that be a good idea?
While I enjoy greatly the benefits of Stimulus, the html bloating annoys me a tad.
Example: (simplified)
I’m writing a web order editor.
Each order can have 30 lines.
Each line has 4 cells (“3L”, “Paint X”, “Red”, “3” $/L")
-> 120 - quasi - identical cells per grid (order)
To track what grid line is current, each cell watches “focus” and “blur”
" focus->#{line#classifyCurrentLine" +
" blur->line#unclassifyCurrentLine "
To track cell changes, each cell watches “keyup”
“keyup->line#refresh_subtotal_and_more”
-> 120 = “data-actions=…”
As I like explicit controllers names that match the Ruby code vocabulary, each data-action can be 300 chars long:
Ex:
data-action="focus->quotation--prod-line-editor#classifyCurrentLine blur->quotation--prod-line-editor#unclassifyCurrentLine keyup->quotation--prod-line-editor#on_unit_price_change keydown->quotation--prod-line-editor#on_tab_insert_new_prod_line change->quotation--prod-line-editor#on_unit_price_change"
120x300 -> 40K characters in one page of very similar “data-action=…”
That makes for a big/bloated/hard to inspect HTML
Any suggestions?