I am currently using:
- remodalJS 0.6.4
- iCheckJS 1.0.2
the UX is designed so that the iCheck checkboxes and radios act as filters and live within a remodal. Weird things happened when I paired up the two libraries to use:
This is the console output from Chrome,
ifChecked
is being fired one time more when a selection is checked (by radio or checkbox).
<html>
<head>
<link rel="stylesheet" href="bower_components/remodal/dist/jquery.remodal.css">
<link rel="stylesheet" href="bower_components/iCheck/skins/line/green.css">
</head>
<body>
<h1 data-remodal-target="test-icheck-remodal"> Animal</h1>
<h1 data-remodal-target="test-icheck-remodal-2"> Comics</h1>
<div class="remodal" data-remodal-id="test-icheck-remodal">
<h2>Choose Animal</h2>
<input type="checkbox" value="">
<label>Cat</label>
<input type="checkbox" value="">
<label>Dog</label>
</div>
<div class="remodal" data-remodal-id="test-icheck-remodal-2">
<h2>Choose Comics</h2>
<input type="checkbox" value="">
<label>Batman</label>
<input type="checkbox" value="">
<label>Superman</label>
</div>
<script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="bower_components/remodal/dist/jquery.remodal.js"></script>
<script type="text/javascript" src="bower_components/iCheck/icheck.js"></script>
<script type="text/javascript">
$('input:checkbox, input:radio').each(function() {
var self = $(this),
label = self.next(),
label_text = label.text();
label.remove();
self.iCheck({
checkboxClass: 'icheckbox_line-green',
radioClass: 'iradio_line-green',
insert: '<div class="icheck_line-icon"></div>' + label_text
})
});
var flag = false;
$(document).on('open', '.remodal', function(e) {
var $this = $(this);
var inputFields = $this.find('input:checkbox, input:radio');
console.log('remodal Opened');
if(!flag) {
inputFields.on('ifChecked', function(event) {
console.log('ifChecked called');
});
flag = true;
}
});
</script>
</body>
</html>
Corresponding bower.json
{
"name": "remodal_icheck",
"version": "0.0.0",
"dependencies": {
"remodal": "0.6.4",
"iCheck": "1.0.2"
},
"devDependencies": {
}
}