form_remote_tagのオプション
- :update
- 更新したいidを指定する
- (:update => 'my_id')
- :url
- url_forに指定するパラメータと同じ
- (:url => {:action => 'create'})
- :failure
- 失敗したときのアクション
- (:failure => "alert('失敗')")
- :complete
- 成功したときのアクション
- (:complete => "alert('成功')")
- :position
- HTML の断片を挿入される位置
- (:position => 'top')
- :html
- HTMLの属性
- (:html => {:id => 'tag_id', :class => 'remote'})
サンプル
<%= form_remote_tag(:update => 'my_id', :url => {:action => 'create'}, :failure => "alert('失敗')", :complete => "alert('成功')", :position => 'top', :html => {:id => 'tag_id', :class => 'remote'}) %> <%= text_field("book", "author") %> <%= submit_tag "Ajax" %> <%= end_form_tag %>