0
0

More than 3 years have passed since last update.

非同期処理に便利なremote: tureオプションを利用する

Posted at

remote: tureの概要

・非同期処理を行ないたいに使う
・link_to もしくは button_to で利用可能。
・button_toで可能ということは、submitでも可能?


Railsには、Ajax機能が組み込まれている
remote: ture オプションで非同期処理が可能。

リクエストが、HTML形式ではなくjs形式なる(ページ遷移をしなくなる)
参考URL:https://qiita.com/__tambo__/items/45211df065e0c037d032

メリット

Railsが自動的にAjaxでサーバにリクエストを送信してくれるため、AjaxのJavascriptコードを自分で書く必要がない

使い方

ex.)link_to の場合

<%= link_to post_favorite_path(@post),method: :delete do, remote: true %>

こんな感じだけど動作しない・・・ぐぬぬぬぬぬぬぬぬぬ

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