0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

htmxを使ってみた-(9)ページの再読み込み-

Last updated at Posted at 2024-10-22

画面の再読込

HTML では、<form>、<a>タグをクリックすると画面が遷移(ページの書き換え)します。
htmxでは、hx-boost="true"属性を<form>、<a>タグに付与することで、画面全体を再読込せずに、<body>タグの中身だけを更新できるような機能があります。
<head>タグ内で、多くのCSS、JavaScript を読み込ませている場合、再度、CSSやJavaScriptを読み込み評価しなくて済むので、処理が軽くなる(?)そうです。

hx-boost属性の利用

練習プログラムでは、「データ再読み込み」ボタンとして使っています。

html00.j2
<form action="/reload_institution" method="get" hx-boost="true" style="display: inline">
	<input type="submit" value="データ再読み込み" title="施設を追加した後に実行すると、名称のヨミガナ順に並び替えます">
</form>

練習プログラムでは、追加したデータを「施設追加」ボタンの上に表示して、追加データの確認を行いやすいようにしています。
06.png
追加の確認は、ボタンのうえに出てきた方が便利ですが、名前から探す場合は、ヨミガナ順に並んでいた方が便利です。
そこで、「データ再読込み」ボタンをつくって、サーバーからヨミガナ順に並べられたデータをもらいます。

関連記事一覧

htmxを使ってみた-(1)htmxの基本-
htmxを使ってみた-(2)準備-
htmxを使ってみた-(3)ルート関数-
htmxを使ってみた-(4)htmxを使う-
htmxを使ってみた-(5)HTMLのdialog-
htmxを使ってみた-(6)データの表示-
htmxを使ってみた-(7)データ追加-
htmxを使ってみた-(8)要素の変更-
htmxを使ってみた-(9)ページの再読み込み-
htmxを使ってみた-(10)データの変更-
htmxを使ってみた-(11)データベースの排他制御-
htmxを使ってみた-(12)確認ダイアローグ-
htmxを使ってみた-(13)データ削除-(最終)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?