I'm not able to bind jQuery events to dynamically created list items.
It's the event on btnRemoveItem
that is not triggering after begin added by jQuery.
$('#btnAddStore').on('click', function(){
(...)
$.ajax({
success: (function(result) {
(...)
var li = jQuery('<li/>', {
'id': object['id']
}).append('<span title="Remove item from list" class="btnRemoveItem"></span>')
.append('<span class="text">' + name_adr[0] + '</span>')
.append('<span class="address">' + name_adr[1] + '</span>');
$(li).appendTo('#'+ country + ' ul');
}
});
});
I've looked at similar questions in here, but I've not found any answers that solves my problem. What am I missing from this code?