I have this Jquery code to be updating checkboxes base on whether a checkbox has been checked. However, This does not fire.
Code
$('body').on('change', '.territory', function () {
var PK = $(this).find('input:checkbox:first').val();
var PKStr = '.parent' + PK;
console.log('change!');
});
$('body').on('change', '.iCheck-helper', function () {
//var PK = $(this).find('input:checkbox:first').val();
//var PKStr = '.parent' + PK;
console.log('change!');
});
<div class="row">
<div class="col-md-12 col-lg-12">
<label class="control-label">
Selected Territories
</label>
</div>
@for (int c = 0; c < 2; ++c)
{
int Count = 0;
<div class="col-md-6 col-lg-6">
@foreach (var ter in Infobase.MMS.Models.ComboBoxValues.GetTerritoryRights(0))
{
if (Count % 2 == c)
{
<label>
<input type="checkbox" class="territory" value="@ter.Key">
@ter.Value
</label>
}
Count++;
}
</div>
}
</div>
I've tried binding to the click function and change function on iCheckbox-Helper as well as directly to the checkboxes. However neither seem to work. Everything does work fine when I dont add in the Icheck.js script.
Does anybody know how to hook into on changed event from bootstraps Icheckhelper class?
Use ifChanged or ifChecked mentioned in the documentation
$('input').on('ifChecked', function(event){
alert(event.type + ' callback');
});
I just added this globally and it does the trick for me.
$(".i-checks input").on('ifChanged', function (e) {
$(this).trigger("change", e);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With