Whenever I try to add an event on an input created dynamically, I am not able to fire an event on it. I am using icheck plugin to customize these inputs, I'm not sure, if the problem come from this.
html
<div id="assurance">
</div>
Function that create input
for(var i =0; i < data.RESPONSE.Products.Product.length; i++){
assurHtml +='<div class="radio" onclick="update_gt();">';
assurHtml +='<label>';
assurHtml +='<input class="i-radio" type="radio" name="manuCode" id="manuCodes" onclick="update_gt();" value="'+data.RESPONSE.Products.Product[i].CODE+'_'+data.RESPONSE.Products.Product[i].NAME+'_'+data.RESPONSE.Products.Product[i].PRICE+'_'+data.RESPONSE.Products.Product[i].TAX+'" />';
assurHtml +='</label>';
assurHtml +='</div>';
}
$('#assurance').html(assurHtml);
$('#assurance input').iCheck({radioClass: 'i-check'});
function update_gt(){
console.log($('input[name=manuCode]:checked').val());
}
$('#assurance').delegate('input[name="manuCode"]', 'click', function(){
console.log("fds");
});
$('#assurance').delegate('input[name="manuCode"]', 'ifToggled', function(){
console.log("fds");
});
update_gt();on click event of div? and why do you need to attach the event again when you have already done that in the dynamic html that you generate?