質問編集履歴
3
出力結果の訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,9 +40,9 @@
|
|
40
40
|
|
41
41
|
<div class="material_field" id="material_field[1]">
|
42
42
|
|
43
|
-
<input placeholder="食材" id="name[1]" type="text" name="recipe[materials_attributes][0][name]">
|
43
|
+
<input placeholder="食材" id="name[1]" type="text" name="recipe[materials_attributes][0][name]" />
|
44
44
|
|
45
|
-
<input placeholder="量" id="amount[1]" type="text" name="recipe[materials_attributes][0][amount]">
|
45
|
+
<input placeholder="量" id="amount[1]" type="text" name="recipe[materials_attributes][0][amount]" />
|
46
46
|
|
47
47
|
</div>
|
48
48
|
|
@@ -122,9 +122,9 @@
|
|
122
122
|
|
123
123
|
<div class="material_field" id="material_field[1]">
|
124
124
|
|
125
|
-
<input placeholder="食材" id="name[1]" type="text" name="recipe[materials_attributes][1][name]">
|
125
|
+
<input placeholder="食材" id="name[1]" type="text" name="recipe[materials_attributes][1][name]" />
|
126
126
|
|
127
|
-
<input placeholder="量" id="amount[1]" type="text" name="recipe[materials_attributes][1][amount]">
|
127
|
+
<input placeholder="量" id="amount[1]" type="text" name="recipe[materials_attributes][1][amount]" />
|
128
128
|
|
129
129
|
</div>
|
130
130
|
|
2
理想の出力結果の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,15 +34,19 @@
|
|
34
34
|
|
35
35
|
<div class="material_field" id="material_field[0]">
|
36
36
|
|
37
|
-
|
37
|
+
<input placeholder="食材" id="name[0]" type="text" name="recipe[materials_attributes][0][name]" />
|
38
38
|
|
39
|
-
|
39
|
+
<input placeholder="量" id="amount[0]" type="text" name="recipe[materials_attributes][0][amount]" />
|
40
40
|
|
41
|
-
|
41
|
+
<div class="material_field" id="material_field[1]">
|
42
42
|
|
43
|
-
|
43
|
+
<input placeholder="食材" id="name[1]" type="text" name="recipe[materials_attributes][0][name]">
|
44
44
|
|
45
|
+
<input placeholder="量" id="amount[1]" type="text" name="recipe[materials_attributes][0][amount]">
|
46
|
+
|
45
|
-
|
47
|
+
</div>
|
48
|
+
|
49
|
+
</div>
|
46
50
|
|
47
51
|
```
|
48
52
|
|
@@ -104,4 +108,38 @@
|
|
104
108
|
|
105
109
|
```
|
106
110
|
|
107
|
-
`text_field:name`の`:name`部分を配列にしたい場合はjqueryでどのように指定したら良いのか分からず質問しました。
|
111
|
+
`text_field:name`の`:name`部分を配列にしたい場合はjqueryでどのように指定したら良いのか分からず質問しました。
|
112
|
+
|
113
|
+
↓理想の出力結果です
|
114
|
+
|
115
|
+
```HTML
|
116
|
+
|
117
|
+
<div class="material_field" id="material_field[0]">
|
118
|
+
|
119
|
+
<input placeholder="食材" id="name[0]" type="text" name="recipe[materials_attributes][0][name]" />
|
120
|
+
|
121
|
+
<input placeholder="量" id="amount[0]" type="text" name="recipe[materials_attributes][0][amount]" />
|
122
|
+
|
123
|
+
<div class="material_field" id="material_field[1]">
|
124
|
+
|
125
|
+
<input placeholder="食材" id="name[1]" type="text" name="recipe[materials_attributes][1][name]">
|
126
|
+
|
127
|
+
<input placeholder="量" id="amount[1]" type="text" name="recipe[materials_attributes][1][amount]">
|
128
|
+
|
129
|
+
</div>
|
130
|
+
|
131
|
+
</div>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
```
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
上手く説明ができていないかもしれませんが、回答よろしくお願いします。
|
1
フレームワークと出力結果の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -25,6 +25,28 @@
|
|
25
25
|
</div>
|
26
26
|
|
27
27
|
```
|
28
|
+
|
29
|
+
↓出力結果です
|
30
|
+
|
31
|
+
```html
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
<div class="material_field" id="material_field[0]">
|
36
|
+
|
37
|
+
<input placeholder="食材" id="name[0]" type="text" name="recipe[materials_attributes][0][name]" />
|
38
|
+
|
39
|
+
<input placeholder="量" id="amount[0]" type="text" name="recipe[materials_attributes][0][amount]" />
|
40
|
+
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<button name="button" type="button" id="add_btn">▽追加する</button>
|
44
|
+
|
45
|
+
</div>
|
46
|
+
|
47
|
+
```
|
48
|
+
|
49
|
+
|
28
50
|
|
29
51
|
|
30
52
|
|