I add the button with the following code:
$('.dishes').prepend($('<div class="row" data-dishid="'+dishid+'"><div class="col-md-8">'+dishname+'<button type="button" class="close" aria-label="Close"><span aria-hidden="true">×</span></button></div></div>'));
But the following code doesn't catch the button click (when it works with the same code if it is part of the static html):
$("button.close").click(function() {
var row = $(this).closest('.row');
var dishid = row.attr('data-dishid');
});
How can I fix that?
See the sample code.