質問編集履歴
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,10 +1,27 @@
|
|
1
1
|
railsのformで<%= f.check_box :unspecified_capacity_flg %>というように作成すれば<input type="chekbox" ...>だけ生成されるものだと思っていたのですが、bootstrapのせいなのか下記のようになります。チェックするとaria-checkedの値がtrueになります。
|
2
2
|
チェックされた時と外れた時のイベントをjqueryで拾いたいのですが、$("icheckbox_square")を指定しても$('#event_schedule_unspecified_capacity_flg')を指定してもchangeまたはclickどちらのイベントも拾うことができません。
|
3
3
|
どのようにすれば良いのでしょうか。
|
4
|
+
|
5
|
+
追記
|
6
|
+
jsを書きました。とりあえずクリックは拾えるようになったのですが、inputフィールドの非活性はできるようになりましたがもう一度クリックした時に元に戻せません。alertは毎回動作します。
|
7
|
+
|
4
8
|
```html
|
5
9
|
<div class="icheckbox_square" aria-checked="false" aria-disabled="false" style="position: relative;">
|
6
10
|
<input type="checkbox" value="1" name="event_schedule[fullhouse_flg]" id="event_schedule_unspecified_capacity_flg" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;">
|
7
11
|
<ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;">
|
8
12
|
</ins>
|
9
13
|
</div>
|
14
|
+
```
|
15
|
+
|
16
|
+
```jquery
|
17
|
+
$(function(){
|
18
|
+
$('ins.iCheck-helper').on('click',function(){
|
19
|
+
alert('aaaaa');
|
20
|
+
if ($('div.icheckbox_square').attr('aria-checked')){
|
21
|
+
$('input#texthoge').prop('disabled', true);
|
22
|
+
}else{
|
23
|
+
$('input#texthoge').prop('disabled', false);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
});
|
10
27
|
```
|