質問編集履歴
1
文面変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -78,13 +78,103 @@
|
|
78
78
|
|
79
79
|
reader.readAsDataURL(fileList[0]);
|
80
80
|
|
81
|
+
|
82
|
+
|
83
|
+
//読み込み後
|
84
|
+
|
85
|
+
reader.onload = function () {
|
86
|
+
|
87
|
+
document.querySelector('#preview').src = reader.result;
|
88
|
+
|
89
|
+
$('#preview').css("display", "inline-block");
|
90
|
+
|
91
|
+
};
|
92
|
+
|
93
|
+
};
|
94
|
+
|
95
|
+
};
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
$("#preview").draggable({
|
100
|
+
|
101
|
+
containment: "parent",
|
102
|
+
|
103
|
+
drag: function(e, ui) {
|
104
|
+
|
105
|
+
$(".x_offset").text(ui.offset.left);
|
106
|
+
|
107
|
+
$(".y_offset").text(ui.offset.top);
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
});
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
});
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
ーーーーーーーーー
|
120
|
+
|
121
|
+
html-------
|
122
|
+
|
123
|
+
<%= javascript_include_tag "corde.js" %>
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
```
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
### 試したこと
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
js内にあるfunctionが原因かと思い、名前を変えてみたのですが、下記別のエラー文が出ます。
|
138
|
+
|
139
|
+
```ここに言語を入力
|
140
|
+
|
141
|
+
エラー文
|
142
|
+
|
143
|
+
Uncaught SyntaxError: Unexpected token {
|
144
|
+
|
145
|
+
ーーーーーー
|
146
|
+
|
147
|
+
js--------
|
148
|
+
|
149
|
+
$(function() {
|
150
|
+
|
151
|
+
var file = document.querySelector('#getphoto');
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
file.onchange = myfunction (){ **←ここに×がつきます。**
|
156
|
+
|
157
|
+
var fileList = file.files;
|
158
|
+
|
159
|
+
if (file.files[0] == null) {
|
160
|
+
|
161
|
+
document.querySelector('#preview').src = "";
|
162
|
+
|
163
|
+
} else {
|
164
|
+
|
165
|
+
//読み込み
|
166
|
+
|
167
|
+
var reader = new FileReader();
|
168
|
+
|
169
|
+
reader.readAsDataURL(fileList[0]);
|
170
|
+
|
81
171
|
// ファイル複数個取得
|
82
172
|
|
83
173
|
|
84
174
|
|
85
175
|
//読み込み後
|
86
176
|
|
87
|
-
reader.onload = function () {
|
177
|
+
reader.onload = myfunction () {
|
88
178
|
|
89
179
|
document.querySelector('#preview').src = reader.result;
|
90
180
|
|
@@ -102,7 +192,7 @@
|
|
102
192
|
|
103
193
|
containment: "parent",
|
104
194
|
|
105
|
-
drag: function(e, ui) {
|
195
|
+
drag: myfunction(e, ui) {
|
106
196
|
|
107
197
|
$(".x_offset").text(ui.offset.left);
|
108
198
|
|
@@ -118,200 +208,6 @@
|
|
118
208
|
|
119
209
|
|
120
210
|
|
121
|
-
ーーーーーーーーー
|
122
|
-
|
123
|
-
html-------
|
124
|
-
|
125
|
-
<%= javascript_include_tag "corde.js" %>
|
126
|
-
|
127
|
-
<!-- コーデ登録 -->
|
128
|
-
|
129
|
-
<div class="corde_container">
|
130
|
-
|
131
|
-
<div class="row">
|
132
|
-
|
133
|
-
<div class="col-lg-4">
|
134
|
-
|
135
|
-
</div>
|
136
|
-
|
137
|
-
<div class="col-lg-8">
|
138
|
-
|
139
|
-
<div class="corde_visual">
|
140
|
-
|
141
|
-
<div class="corde_visual_image"></div>
|
142
|
-
|
143
|
-
<%#= image_tag 'image_item.jpg' ,class: "corde_visual_image" %>
|
144
|
-
|
145
|
-
</div>
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
<h1>コーデ登録</h1>
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
<div class="image_box">
|
154
|
-
|
155
|
-
<img src="" id="preview" class="corde_image ui-draggable ui-draggable-handle" style="position: relative;">
|
156
|
-
|
157
|
-
</div>
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
<%= form_for(@corde_new, url: new_corde_path) do |f| %>
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
<input type="image" name="corde[image]" id="preview" />
|
166
|
-
|
167
|
-
<input type="file" name="attachment" id="getphoto" />
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
<label for="name">▷コーデ名</label>
|
172
|
-
|
173
|
-
<input type="text" name="corde[corde_name]" id="corde_corde_name" />
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
<label for="name">▷シーズン</label>
|
178
|
-
|
179
|
-
<input type="radio" name="corde[season]" value="春" id="corde_season" />春
|
180
|
-
|
181
|
-
<input type="radio" name="corde[season]" value="夏" id="corde_season" />夏
|
182
|
-
|
183
|
-
<input type="radio" name="corde[season]" value="秋" id="corde_season" />秋
|
184
|
-
|
185
|
-
<input type="radio" name="corde[season]" value="冬" id="corde_season" />冬
|
186
|
-
|
187
|
-
<%= f.submit'保存' %>
|
188
|
-
|
189
|
-
<% end %>
|
190
|
-
|
191
|
-
</div>
|
192
|
-
|
193
|
-
</div>
|
194
|
-
|
195
|
-
</div>
|
196
|
-
|
197
|
-
ーーーーーーーーーー
|
198
|
-
|
199
|
-
css-------
|
200
|
-
|
201
|
-
.corde_visual {
|
202
|
-
|
203
|
-
width: 800px;
|
204
|
-
|
205
|
-
height: 300px
|
206
|
-
|
207
|
-
background-color: green;
|
208
|
-
|
209
|
-
}
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
.corde_visual_image {
|
214
|
-
|
215
|
-
background-image: url("/assets/image_item.jpg");
|
216
|
-
|
217
|
-
width: 100%;
|
218
|
-
|
219
|
-
height: 100%;
|
220
|
-
|
221
|
-
display: block;
|
222
|
-
|
223
|
-
}
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
ーーーーーーーーーーーー
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
```
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
### 試したこと
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
js内にあるfunctionが原因かと思い、名前を変えてみたのですが、下記別のエラー文が出ます。
|
242
|
-
|
243
|
-
```ここに言語を入力
|
244
|
-
|
245
|
-
エラー文
|
246
|
-
|
247
|
-
Uncaught SyntaxError: Unexpected token {
|
248
|
-
|
249
|
-
ーーーーーー
|
250
|
-
|
251
|
-
js--------
|
252
|
-
|
253
|
-
$(function() {
|
254
|
-
|
255
|
-
var file = document.querySelector('#getphoto');
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
file.onchange = myfunction (){ **←ここに×がつきます。**
|
260
|
-
|
261
|
-
var fileList = file.files;
|
262
|
-
|
263
|
-
if (file.files[0] == null) {
|
264
|
-
|
265
|
-
document.querySelector('#preview').src = "";
|
266
|
-
|
267
|
-
} else {
|
268
|
-
|
269
|
-
//読み込み
|
270
|
-
|
271
|
-
var reader = new FileReader();
|
272
|
-
|
273
|
-
reader.readAsDataURL(fileList[0]);
|
274
|
-
|
275
|
-
// ファイル複数個取得
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
//読み込み後
|
280
|
-
|
281
|
-
reader.onload = myfunction () {
|
282
|
-
|
283
|
-
document.querySelector('#preview').src = reader.result;
|
284
|
-
|
285
|
-
$('#preview').css("display", "inline-block");
|
286
|
-
|
287
|
-
};
|
288
|
-
|
289
|
-
};
|
290
|
-
|
291
|
-
};
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
$("#preview").draggable({
|
296
|
-
|
297
|
-
containment: "parent",
|
298
|
-
|
299
|
-
drag: myfunction(e, ui) {
|
300
|
-
|
301
|
-
$(".x_offset").text(ui.offset.left);
|
302
|
-
|
303
|
-
$(".y_offset").text(ui.offset.top);
|
304
|
-
|
305
|
-
}
|
306
|
-
|
307
|
-
});
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
});
|
312
|
-
|
313
|
-
|
314
|
-
|
315
211
|
```
|
316
212
|
|
317
213
|
|