I'm trying to create a script that will save a ticked checkbox. The code I have as of now disables add & approve when read is ticked and disables read when either of add/approve is ticked. Now the problem I have is when I added ajax submission to the jquery it doesn't save the record and it no longer disables the checkboxes(assuming I ticked read).
Here's what I got so far.
$(document).ready(function(){
$('#list-tbl tr').each(function(){
var $this = $(this);
var id = $('#input').val();
$('input[type=checkbox]', $this).change(function(){
if($('.read', $this).is(':checked')){
$('input[type=checkbox]', $this).prop('disabled',true);
$.ajax({
type: 'POST',
url: <?= site_url('admin/update')?>,
dataType: "json",
data: { id: id },
success: function(data) {
alert("Updated");
}
});
$(this).prop('disabled',false);
} else if($('.add', $this).is(':checked') || $('.approve', $this).is(':checked')) {
$('.read', $this).prop('disabled', true);
$(this).prop('disabled', false);
} else{
$('input[type=checkbox]', $this).prop('disabled',false);
$(this).prop('disabled',false);
}
});
});
});
Ex: http://jsfiddle.net/bGatX/
I'm getting a lil bit frustrated I just want to save the data in the right manner and perform the disabling as it is....
Many thanks.