質問編集履歴
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -43,6 +43,8 @@
|
|
43
43
|
```
|
44
44
|
|
45
45
|
間違っている箇所があればご指摘、ご教示お願い致します
|
46
|
+
|
47
|
+
実現不可能であれば、その旨の回答頂けると助かります
|
46
48
|
|
47
49
|
### 参考にした情報
|
48
50
|
|
2
調査の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -102,6 +102,10 @@
|
|
102
102
|
|
103
103
|
}
|
104
104
|
|
105
|
+
//ここでダイアログの選択値とコールバックを使用しているっぽそう
|
106
|
+
|
107
|
+
//そのため、ダイアログの選択値を持ってくるのは出来なさそうに見える。。。
|
108
|
+
|
105
109
|
return answer && callback;
|
106
110
|
|
107
111
|
},
|
1
調査の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
### 問題
|
14
14
|
|
15
|
-
r
|
15
|
+
answerの値がundefinedになってしまい、testFunc関数が実行されないです
|
16
16
|
|
17
17
|
### 該当のソースコード
|
18
18
|
|
@@ -20,9 +20,9 @@
|
|
20
20
|
|
21
21
|
$(function () {
|
22
22
|
|
23
|
-
$("*[name=target_item]").on("confirm:complete", function(event, r
|
23
|
+
$("*[name=target_item]").on("confirm:complete", function(event, answer){
|
24
24
|
|
25
|
-
if(r
|
25
|
+
if(answer){
|
26
26
|
|
27
27
|
testFunc();
|
28
28
|
|
@@ -48,6 +48,70 @@
|
|
48
48
|
|
49
49
|
http://inter-arteq.com/2016/06/30/railsconfirm%E3%81%A7ok%E3%81%97%E3%81%9F%E3%81%A8%E3%81%8D%E3%81%A0%E3%81%91js%E3%82%92%E5%8B%95%E4%BD%9C%E3%81%95%E3%81%9B%E3%82%8B%E6%96%B9%E6%B3%95/
|
50
50
|
|
51
|
+
|
52
|
+
|
53
|
+
2018/11/13 17:45 追記
|
54
|
+
|
55
|
+
https://github.com/rails/jquery-ujs/blob/master/src/rails.js
|
56
|
+
|
57
|
+
を参照すると
|
58
|
+
|
59
|
+
```js
|
60
|
+
|
61
|
+
/* For 'data-confirm' attribute:
|
62
|
+
|
63
|
+
- Fires `confirm` event
|
64
|
+
|
65
|
+
- Shows the confirmation dialog
|
66
|
+
|
67
|
+
- Fires the `confirm:complete` event
|
68
|
+
|
69
|
+
Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
|
70
|
+
|
71
|
+
Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
|
72
|
+
|
73
|
+
Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
|
74
|
+
|
75
|
+
return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
|
76
|
+
|
77
|
+
*/
|
78
|
+
|
79
|
+
allowAction: function(element) {
|
80
|
+
|
81
|
+
var message = element.data('confirm'),
|
82
|
+
|
83
|
+
answer = false, callback;
|
84
|
+
|
85
|
+
if (!message) { return true; }
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
if (rails.fire(element, 'confirm')) {
|
90
|
+
|
91
|
+
try {
|
92
|
+
|
93
|
+
answer = rails.confirm(message);
|
94
|
+
|
95
|
+
} catch (e) {
|
96
|
+
|
97
|
+
(console.error || console.log).call(console, e.stack || e);
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
callback = rails.fire(element, 'confirm:complete', [answer]);
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
return answer && callback;
|
106
|
+
|
107
|
+
},
|
108
|
+
|
109
|
+
```
|
110
|
+
|
111
|
+
となっており、今現在だとanswerの値を取得するのはできなさそう。。。?
|
112
|
+
|
113
|
+
|
114
|
+
|
51
115
|
### 補足情報(FW/ツールのバージョンなど)
|
52
116
|
|
53
117
|
・ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]
|