質問編集履歴
1
_item.html.erbを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -178,6 +178,108 @@
|
|
178
178
|
|
179
179
|
|
180
180
|
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
以下部分テンプレートです。
|
186
|
+
|
187
|
+
_item.html.erb
|
188
|
+
|
189
|
+
```
|
190
|
+
|
191
|
+
<li class="idea">
|
192
|
+
|
193
|
+
<div class="idea-text">
|
194
|
+
|
195
|
+
<div class="checked-item_<%= "#{item_counter}"%>" >
|
196
|
+
|
197
|
+
<% if item.check == true %>
|
198
|
+
|
199
|
+
<div class="delete-text">
|
200
|
+
|
201
|
+
<%= item.text %>
|
202
|
+
|
203
|
+
</div>
|
204
|
+
|
205
|
+
<% else %>
|
206
|
+
|
207
|
+
<%= item.text %>
|
208
|
+
|
209
|
+
<% end %>
|
210
|
+
|
211
|
+
</div>
|
212
|
+
|
213
|
+
</div>
|
214
|
+
|
215
|
+
<div class="item-menu-right">
|
216
|
+
|
217
|
+
<%= link_to item_path(item), method: :delete , data:{ confirm: '本当によろしいですか?'}, remote: true do %>
|
218
|
+
|
219
|
+
<i class="fa fa-trash fa-fw" aria-hidden="true"></i>
|
220
|
+
|
221
|
+
<% end %>
|
222
|
+
|
223
|
+
<!-- ここをモーダルにする -->
|
224
|
+
|
225
|
+
<%= link_to edit_item_path(item), method: :get ,class: "fa-edit-margin", item_id: item.id do %>
|
226
|
+
|
227
|
+
<i class="fa fa-edit fa-fw" aria-hidden="true" ></i>
|
228
|
+
|
229
|
+
<% end %>
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
<%= check_box_tag '', '', item.check, {'data-id' => item.id, 'data-user-id' => item.user_id ,class: "check_#{item_counter} option-input"} %>
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
</div>
|
238
|
+
|
239
|
+
</li>
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
<!-- idからclass指定に変えた -->
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
<!-- チェックつけたらdelete-textつける -->
|
248
|
+
|
249
|
+
<!-- item_counterを使い、各テンプレートに連番を振っている -->
|
250
|
+
|
251
|
+
<script>
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
$(function() {
|
256
|
+
|
257
|
+
$('.check_<%= "#{item_counter}"%>').on('click', function() {
|
258
|
+
|
259
|
+
if ( $(this).prop('checked') == false ) {
|
260
|
+
|
261
|
+
$('.checked-item_<%= "#{item_counter}"%>').removeClass("delete-text");
|
262
|
+
|
263
|
+
} else {
|
264
|
+
|
265
|
+
$('.checked-item_<%= "#{item_counter}"%>').addClass("delete-text");
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
});
|
270
|
+
|
271
|
+
});
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
</script>
|
278
|
+
|
279
|
+
```
|
280
|
+
|
281
|
+
|
282
|
+
|
181
283
|
### 試したこと
|
182
284
|
|
183
285
|
|