I have the next code
$.ajax({
                url: '/data',
                type: "POST",
                data: JSON.stringify(formData),
                contentType: "application/json",
                dataType: "json",
                success: function(response){
                    for (var i=0; i<response.length; i++) {
                        var htmlEdit = "creating button here";
                        var btnEdit = jQuery(htmlEdit);
                        btnEdit.appendTo(divCollapse);
                        btnEdit.click(function() {
                            editBooking(btnEdit);
                        });
                    }
               }
});
function editBooking(btn) {
    btn.button('loading');
}
So I have rows with identical items. Buttons are shown as expected. Click to any button invokes loading state for the last button. What I'm doing wrong? Thank you.
 
    