回答編集履歴
2
追記
answer
CHANGED
@@ -13,4 +13,17 @@
|
|
13
13
|
<%# destroy.js.erb %>
|
14
14
|
$('<%= "#follow_form_#{@user.id}" %>').html('<%= escape_javascript(render("relationships/follow_button", user: @user )) %>');
|
15
15
|
```
|
16
|
-
erbの書き方に慣れてないのでもしかしたら書き方違うかも。
|
16
|
+
erbの書き方に慣れてないのでもしかしたら書き方違うかも。
|
17
|
+
|
18
|
+
### 追記
|
19
|
+
もしかして...
|
20
|
+
|
21
|
+
```erb
|
22
|
+
<%# relationships/_follow_button.html.erb %>
|
23
|
+
<div class='follow_form_<%= user.id %>>
|
24
|
+
```
|
25
|
+
```erb
|
26
|
+
<%# create.js.erb %>
|
27
|
+
<%# destroy.js.erb %>
|
28
|
+
$('<%= ".follow_form_#{@user.id}" %>').html('<%= escape_javascript(render("relationships/follow_button", user: @user )) %>');
|
29
|
+
```
|
1
誤字
answer
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
同一ページ内に`id="follow_form"`の要素が複数個存在しているのが原因です。
|
2
2
|
jsの`$("<%= '#follow_form' %>")`は最初に見つかった`#follow_form`要素を返すので
|
3
3
|
最新のものしかフォローが反映されないと思ったのもそのためでしょう。
|
4
|
-
同一ページ内で要素のIDが重複しないよにしましょう。
|
4
|
+
同一ページ内で要素のIDが重複しないようにしましょう。
|
5
5
|
|
6
6
|
ex.
|
7
7
|
```erb
|