I see many questions on this topic but none have resolved my issue.
Trouble is: I have a checkbox and need the new value of the checked property when a user clicks it.
I have tried the different event attachers like on.("change" .. and .change(function() .. but always it returns "undefined". I have also tested (with alerts) if the assignment to the variables was done more then once, but they dont. Just once.
Please consider the script and tell me if you know what I am doing wrong. Or if i should post more info.
$(document).ready(function () {
$('#invoice_list :checkbox').on('change', function () {
var _invoice_id;
var _payed;
var _sent;
$(this).parent().siblings().each(function () {
if ($(this).hasClass('name?ajax_invoice_id')) {
_invoice_id = $(this).text();
}
if ($(this).hasClass('name?ajax_payed')) {
_payed = $(this).children(':checkbox').prop('checked');
}
if ($(this).hasClass('name?ajax_sent')) {
_sent = $(this).children(':checkbox').prop('checked');
}
});
alert('invoice_id: ' + _invoice_id + '\r\npayed: ' + _payed + '\r\nsent: ' + _sent);
});
});
If i check the "payed" checkbox this is the result no matter the new value (same goes for "sent"): localhost says
Aucun commentaire:
Enregistrer un commentaire