I'm having trouble grasping how to use jquery .trigger(). I'm simply looping around checkboxes and finding which checkboxes have been checked. I am then trying to map those values to a key value pair. If I log paymentValue and paymentName I get the correct output which would be something like: cash and true so I want something like cash : true in my key value. Except when I try to run this code I get a paymentName is not defined error
var filterPayment = $('input[name="filter-payment"]:checked');
var paymentObj = {};
$(document).bind("updateFilters", function() {
filterPayment.each( function () {
var paymentValue = paymentObj[this.value];
paymentValue = this.checked;
var paymentName = userObj[this.name];
paymentName = this.value;
});
});
$(document).trigger('updateFilters', {
paymentValue : paymentName
});
Any ideas?
paymentNameis not declared... it is declared in the local scope of theeachcallbackupdateFiltersevent for eachinput[name="filter-payment"]:checkedelement?