質問編集履歴
3
e.preventDefaultの記述箇所変更の反映
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,6 +66,10 @@
|
|
66
66
|
|
67
67
|
submit.addEventListener("click", (e) => {
|
68
68
|
|
69
|
+
|
70
|
+
|
71
|
+
e.preventDefault();
|
72
|
+
|
69
73
|
const formData = new FormData(document.getElementById("form"));
|
70
74
|
|
71
75
|
const XHR = new XMLHttpRequest();
|
@@ -120,8 +124,6 @@
|
|
120
124
|
|
121
125
|
formText.value = "";
|
122
126
|
|
123
|
-
e.preventDefault();
|
124
|
-
|
125
127
|
};
|
126
128
|
|
127
129
|
});
|
2
consoleに表示されているエラーを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -254,11 +254,23 @@
|
|
254
254
|
|
255
255
|
</div>
|
256
256
|
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
```
|
257
|
+
```
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
## 生じているconsoleエラー
|
262
|
+
|
263
|
+
```
|
264
|
+
|
265
|
+
message.js:4 Uncaught TypeError: Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.
|
266
|
+
|
267
|
+
at HTMLInputElement.<anonymous> (message.js:4)
|
268
|
+
|
269
|
+
```
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
262
274
|
|
263
275
|
|
264
276
|
|
1
チャットルームのHTMLビューファイルを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -136,6 +136,132 @@
|
|
136
136
|
|
137
137
|
|
138
138
|
|
139
|
+
## 記述したHTMLビューファイル
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
```html
|
144
|
+
|
145
|
+
<div class="messages", id="message">
|
146
|
+
|
147
|
+
<div class="chat-header">
|
148
|
+
|
149
|
+
<div class="left-button">
|
150
|
+
|
151
|
+
<%= link_to '〇〇さんとのチャットルーム', root_path %>
|
152
|
+
|
153
|
+
</div>
|
154
|
+
|
155
|
+
<div class="room-exit"><%= link_to 'トップページに戻る', root_path %></div>
|
156
|
+
|
157
|
+
</div>
|
158
|
+
|
159
|
+
<% @entries.each do |e| %>
|
160
|
+
|
161
|
+
<div class="user-name">
|
162
|
+
|
163
|
+
<strong>
|
164
|
+
|
165
|
+
<% if e.user.avatar.attached? %>
|
166
|
+
|
167
|
+
<%= image_tag e.user.avatar, class:"icon-image" %>
|
168
|
+
|
169
|
+
<% end %>
|
170
|
+
|
171
|
+
<a class="room-user-link" href="/users/<%= e.user.id %>">
|
172
|
+
|
173
|
+
<%= e.user.name%>さん
|
174
|
+
|
175
|
+
</a>
|
176
|
+
|
177
|
+
</strong>
|
178
|
+
|
179
|
+
</div>
|
180
|
+
|
181
|
+
<% end %>
|
182
|
+
|
183
|
+
<hr>
|
184
|
+
|
185
|
+
<div class="chats">
|
186
|
+
|
187
|
+
<div class="chat">
|
188
|
+
|
189
|
+
<% if @messages.present? %>
|
190
|
+
|
191
|
+
<% @messages.each do |m| %>
|
192
|
+
|
193
|
+
<div class="chat-box">
|
194
|
+
|
195
|
+
<div class="chat-face">
|
196
|
+
|
197
|
+
<% if m.user.avatar.attached? %>
|
198
|
+
|
199
|
+
<%= image_tag m.user.avatar, class:"icon-image-mini" %>
|
200
|
+
|
201
|
+
<% end %>
|
202
|
+
|
203
|
+
</div>
|
204
|
+
|
205
|
+
<div class="chat-message"><strong><%= m.content %></strong><br>
|
206
|
+
|
207
|
+
<%= l m.created_at %>
|
208
|
+
|
209
|
+
</div>
|
210
|
+
|
211
|
+
</div>
|
212
|
+
|
213
|
+
<% end %>
|
214
|
+
|
215
|
+
<% end %>
|
216
|
+
|
217
|
+
<div id="list" ></div>
|
218
|
+
|
219
|
+
</div>
|
220
|
+
|
221
|
+
</div>
|
222
|
+
|
223
|
+
</div>
|
224
|
+
|
225
|
+
<div id="chat">
|
226
|
+
|
227
|
+
<span id="video-end">ビデオ通話を止める</span>
|
228
|
+
|
229
|
+
<chat />
|
230
|
+
|
231
|
+
</div>
|
232
|
+
|
233
|
+
<%= javascript_pack_tag 'chat' %>
|
234
|
+
|
235
|
+
<%= stylesheet_pack_tag 'chat' %>
|
236
|
+
|
237
|
+
<div class="form">
|
238
|
+
|
239
|
+
<%= form_for @message, id: "form", class: "post" do |f| %>
|
240
|
+
|
241
|
+
<div class="post-message">
|
242
|
+
|
243
|
+
<%= f.text_field :content, placeholder: "メッセージを入力してください", size: 70, class:"form-text-field", id:"content-message" %>
|
244
|
+
|
245
|
+
<%= f.hidden_field :room_id, value: @room.id %>
|
246
|
+
|
247
|
+
<%= f.submit '送信', class:"form-submit", id: "submit" %>
|
248
|
+
|
249
|
+
<input type="button" value="ビデオ通話を始める", class="form-submit", id= "video-button">
|
250
|
+
|
251
|
+
</div>
|
252
|
+
|
253
|
+
<% end %>
|
254
|
+
|
255
|
+
</div>
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
```
|
262
|
+
|
263
|
+
|
264
|
+
|
139
265
|
## 試したこと
|
140
266
|
|
141
267
|
|