回答編集履歴
3
修正
test
CHANGED
@@ -218,7 +218,7 @@
|
|
218
218
|
|
219
219
|
$li = $('<li />'),
|
220
220
|
|
221
|
-
$img = $('<img />').attr('src', src)
|
221
|
+
$img = $('<img />').attr('src', src),
|
222
222
|
|
223
223
|
$text = $('<p />').text(name);
|
224
224
|
|
2
追記
test
CHANGED
@@ -285,3 +285,33 @@
|
|
285
285
|
});
|
286
286
|
|
287
287
|
```
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
追記ですが、groupVal, placeVal, genreValを求める部分を共通の関数で処理するよう
|
292
|
+
|
293
|
+
下記の形に書き換えることも出来ます。
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
```js
|
298
|
+
|
299
|
+
getVal: function(key, value){
|
300
|
+
|
301
|
+
return DB[key][value] || [];
|
302
|
+
|
303
|
+
},
|
304
|
+
|
305
|
+
changeList: function() {
|
306
|
+
|
307
|
+
var groupVal = this.getVal('group', this.$group.val()),
|
308
|
+
|
309
|
+
placeVal = this.getVal('place', this.$place.val()),
|
310
|
+
|
311
|
+
genreVal = this.getVal('genre', this.$genre.val()),
|
312
|
+
|
313
|
+
// 以下同様
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
```
|
1
修正
test
CHANGED
@@ -218,15 +218,11 @@
|
|
218
218
|
|
219
219
|
$li = $('<li />'),
|
220
220
|
|
221
|
-
$img = $('<img />'),
|
221
|
+
$img = $('<img />').attr('src', src);
|
222
|
-
|
222
|
+
|
223
|
-
$text = $('<p />');
|
223
|
+
$text = $('<p />').text(name);
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
224
|
+
|
228
|
-
|
229
|
-
|
225
|
+
|
230
226
|
|
231
227
|
$li.append($img, $text);
|
232
228
|
|
@@ -248,37 +244,31 @@
|
|
248
244
|
|
249
245
|
changeList: function() {
|
250
246
|
|
251
|
-
this.$searchcontainer.empty();
|
252
|
-
|
253
|
-
|
254
|
-
|
255
247
|
var groupVal = DB.group[this.$group.val()] || [],
|
256
248
|
|
257
249
|
placeVal = DB.place[this.$place.val()] || [],
|
258
250
|
|
259
251
|
genreVal = DB.genre[this.$genre.val()] || [],
|
260
252
|
|
261
|
-
result;
|
253
|
+
result = $.unique(groupVal.concat(placeVal, genreVal));
|
262
254
|
|
263
255
|
|
264
256
|
|
265
257
|
console.log(groupVal, placeVal, genreVal);
|
266
258
|
|
259
|
+
console.log('result', result);
|
260
|
+
|
267
261
|
|
268
262
|
|
269
|
-
result = $.unique(groupVal.concat(placeVal, genreVal));
|
270
|
-
|
271
|
-
console.log('result', result);
|
272
|
-
|
273
|
-
|
274
|
-
|
275
263
|
if(result.length === 0){
|
276
264
|
|
277
265
|
result = DB.all;
|
278
266
|
|
279
267
|
}
|
280
268
|
|
269
|
+
|
270
|
+
|
281
|
-
|
271
|
+
this.$searchcontainer.empty();
|
282
272
|
|
283
273
|
this.showResult(result);
|
284
274
|
|