回答編集履歴
1
修正
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
修正版
|
2
2
|
|
3
3
|
```javascript
|
4
4
|
|
@@ -6,13 +6,7 @@
|
|
6
6
|
|
7
7
|
$(function () {
|
8
8
|
|
9
|
-
$('#main').on('click','.js-delete',function(e){
|
10
|
-
|
11
|
-
|
9
|
+
var yasai_all;
|
12
|
-
|
13
|
-
$(this).closest('p').remove();
|
14
|
-
|
15
|
-
});
|
16
10
|
|
17
11
|
$.ajax({
|
18
12
|
|
@@ -22,13 +16,31 @@
|
|
22
16
|
|
23
17
|
}).done(function(data){
|
24
18
|
|
25
|
-
|
19
|
+
yasai_all=data;
|
26
20
|
|
21
|
+
view_yasai();
|
22
|
+
|
23
|
+
});
|
24
|
+
|
25
|
+
$('#main').on('click','.js-delete',function(e){
|
26
|
+
|
27
|
+
e.preventDefault();
|
28
|
+
|
29
|
+
$(this).closest('p').remove();
|
30
|
+
|
31
|
+
view_yasai();
|
32
|
+
|
33
|
+
});
|
34
|
+
|
35
|
+
function view_yasai(){
|
36
|
+
|
37
|
+
$('#form_select_yasai option:not(:first)').remove();
|
38
|
+
|
27
|
-
$.each(
|
39
|
+
$.each(yasai_all,function(){
|
28
40
|
|
29
41
|
var name=$(this).get(0).name;
|
30
42
|
|
31
|
-
if($.inArray(name,yasai)==-1){
|
43
|
+
if($.inArray(name,get_yasai())==-1){
|
32
44
|
|
33
45
|
$('#form_select_yasai').append($('<option>').val(name).text(name));
|
34
46
|
|
@@ -36,7 +48,19 @@
|
|
36
48
|
|
37
49
|
});
|
38
50
|
|
39
|
-
}
|
51
|
+
}
|
52
|
+
|
53
|
+
function get_yasai(){
|
54
|
+
|
55
|
+
return $('.list').map(function(){
|
56
|
+
|
57
|
+
return $(this).text();
|
58
|
+
|
59
|
+
}).get();
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
|
40
64
|
|
41
65
|
$('#form_select_yasai').on('change',function(){
|
42
66
|
|