質問編集履歴
3
\.liveを\.onに変更、初期化位置を修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
//表示順序を下に変更
|
20
20
|
|
21
|
-
$("#custom-display-post-widget #item li
|
21
|
+
$("#custom-display-post-widget #item li").on("click", ".down", function() {
|
22
22
|
|
23
23
|
var now_index = $(this).closest("li").index() + 1;
|
24
24
|
|
@@ -32,7 +32,9 @@
|
|
32
32
|
|
33
33
|
$("#custom-display-post-widget #display-setting #item ul li:nth-child("+now_index+")").html(next_obj);
|
34
34
|
|
35
|
+
$("#custom-display-post-widget #item li input").removeAttr('checked');//追記
|
36
|
+
|
35
|
-
|
37
|
+
checkVal();
|
36
38
|
|
37
39
|
});
|
38
40
|
|
@@ -40,7 +42,7 @@
|
|
40
42
|
|
41
43
|
//表示順序を上に変更
|
42
44
|
|
43
|
-
$("#custom-display-post-widget #item li
|
45
|
+
$("#custom-display-post-widget #item li").on("click", ".up", function() {
|
44
46
|
|
45
47
|
var now_index = $(this).closest("li").index() + 1;
|
46
48
|
|
@@ -54,7 +56,9 @@
|
|
54
56
|
|
55
57
|
$("#custom-display-post-widget #display-setting #item ul li:nth-child("+now_index+")").html(prev_obj);
|
56
58
|
|
59
|
+
$("#custom-display-post-widget #item li input").removeAttr('checked');//追記
|
60
|
+
|
57
|
-
|
61
|
+
checkVal();
|
58
62
|
|
59
63
|
});
|
60
64
|
|
@@ -98,19 +102,19 @@
|
|
98
102
|
|
99
103
|
function checkVal(){
|
100
104
|
|
101
|
-
|
105
|
+
var checkBox=[];
|
102
106
|
|
103
|
-
|
107
|
+
// チェックされた値を取得
|
104
108
|
|
105
|
-
|
109
|
+
$("#custom-display-post-widget #item li input:checked").each(function(){
|
106
110
|
|
107
|
-
checkBox.push($(this).val());
|
111
|
+
checkBox.push($(this).val());
|
108
112
|
|
109
|
-
});
|
113
|
+
});
|
110
114
|
|
111
|
-
//取得した値を input text にセット
|
115
|
+
//取得した値を input text にセット
|
112
116
|
|
113
|
-
$("#custom-display-post-widget input.display-post-set").val(checkBox);
|
117
|
+
$("#custom-display-post-widget input.display-post-set").val(checkBox);
|
114
118
|
|
115
119
|
}
|
116
120
|
|
2
症状の詳細を追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
複数のチェックボックスを任意の順番に並び替えしたのち、チェックがついているものの値を一括取得したいのですが、チェックがついた状態のものの順番を変更すると一括取得した値が重複してしまいます。
|
2
2
|
|
3
3
|
対処方法わかる方おりませんでしょうか。
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
《追記》
|
8
|
+
|
9
|
+
チェックボックスのチェックがない状態で順序を変更後、チェックボックスにチェックを入れる場合は問題ないようです。
|
10
|
+
|
11
|
+
チェックボックスにチェックが入ったものを順序変更した場合のみ、チェックが入った値が1つ増えます(重複)します。その後はいくら順序を変更しても重複した値を増えません。
|
12
|
+
|
13
|
+
|
4
14
|
|
5
15
|
```javascript
|
6
16
|
|
1
配列の初期化を追加し、関数名を変更。
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
$("#custom-display-post-widget #display-setting #item ul li:nth-child("+now_index+")").html(next_obj);
|
24
24
|
|
25
|
-
|
25
|
+
checkVal();
|
26
26
|
|
27
27
|
});
|
28
28
|
|
@@ -44,7 +44,7 @@
|
|
44
44
|
|
45
45
|
$("#custom-display-post-widget #display-setting #item ul li:nth-child("+now_index+")").html(prev_obj);
|
46
46
|
|
47
|
-
|
47
|
+
checkVal();
|
48
48
|
|
49
49
|
});
|
50
50
|
|
@@ -80,25 +80,27 @@
|
|
80
80
|
|
81
81
|
|
82
82
|
|
83
|
-
|
83
|
+
checkVal();
|
84
84
|
|
85
85
|
});
|
86
86
|
|
87
87
|
|
88
88
|
|
89
|
-
function
|
89
|
+
function checkVal(){
|
90
90
|
|
91
91
|
// チェックされた値を取得
|
92
92
|
|
93
93
|
$("#custom-display-post-widget #item li input:checked").each(function(){
|
94
94
|
|
95
|
+
var checkBox=[];
|
96
|
+
|
95
|
-
|
97
|
+
checkBox.push($(this).val());
|
96
98
|
|
97
99
|
});
|
98
100
|
|
99
101
|
//取得した値を input text にセット
|
100
102
|
|
101
|
-
$("#custom-display-post-widget input.display-post-set").val(check);
|
103
|
+
$("#custom-display-post-widget input.display-post-set").val(checkBox);
|
102
104
|
|
103
105
|
}
|
104
106
|
|