-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
taskWork, todo, refactor by maintainers; see also 'ask' labelWork, todo, refactor by maintainers; see also 'ask' label
Description
hx-vals='{"product_ids": [1, 2]}' を使って商品のリストをHTMLに埋め込みましょう。この属性値は hx-get/post が定義されている要素全てに付与する必要はなく、親要素に指定するだけで大丈夫なはずです。
ただし、ホーム画面に戻ったときにリストの情報が失われてしまうことが問題です。当初はこの問題を解決するためにCookieを使っていましたが、今になって考え直してみるとREST的でない実装になってしまってます。例えば、独自のhtmx拡張機能 session-storage を実装して、 hx-ext="session-storage" session-storage='{"product_ids": [1, 2]}' hx-vals='js:{"product-ids": sessionStorage.getItem("product-ids")}' のような形でやれば出来る気がします。
参考文献:
Metadata
Metadata
Assignees
Labels
taskWork, todo, refactor by maintainers; see also 'ask' labelWork, todo, refactor by maintainers; see also 'ask' label