LoginSignup
2
2

More than 5 years have passed since last update.

Ajaxの範囲は最小限にすべし

Posted at

検索フォームを入力して検索し、その結果を編集したとき、
ページ全体を再描画するのは効率が悪い。
検索フォームに入力された値が保持されないためだ。
新規作成や削除はともかく、更新であるならば今表示されているレコードの要素を
renderするだけで事足りる。
データ量も削減出来て一石二鳥。

update.js.erb
$("<%= escape_javascript("#result__sample#{@sample.id}") %>").html("<%= escape_javascript(render 'sample') %>");
2
2
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
2
2