In my knockout application I have a forEach loop inside which there is a checkbox repeating for each element.
I'm trying to bind the click event for the checkbox but somehow it doesnt get triggered i have other click events bound to other elements which work fine but only the checkbox one is causing problem
Below is the checkbox
<td>
<div class="form-group margin-top-sm margin-bottom-sm">
<div class="checkbox switch ">
<label for="IsActive" class="dis-block">
<input class="access-hide" id="IsActive" name="IsActive" type="checkbox" data-bind="value:$data.IsActive,click:ChangeStatus,checked: $data.Status(),attr: {id: $data.Id}"><span class="switch-toggle switch-toggle-blue"></span>
</label>
</div>
</div>
</td>
ChangeStatus = function (data, event) {
var value = event.target.checked;
$.ajax({
url: "anc/abc",
type: 'POST',
data: {
"id": data.Id,
"value": value
},
datatype: 'application/json',
success: function (result) {
console.log(result);
if (result.status === "Success") {
if (value) {
SuccessMessage("enabled successfully");
data.Status(true);
}
else {
SuccessMessage("disabled successfully");
data.Status(false);
}
}
},
error: function () {
}
});
return true;
}
The ChangeStatus method is not getting hit only..
Not able to find a solution
Please guide
Thanks Shruti Nair
Aucun commentaire:
Enregistrer un commentaire