I am adding rows with a button that is working now, but I have another button to delete and is not working. This is my code in JS:
jQuery(document).ready(function () {
var collectionCount = 0;
jQuery('#add-another-collection').click(function (e) {
e.preventDefault();
var collectionList = jQuery('#collection-fields-list');
var newWidget = collectionList.attr('data-prototype');
newWidget = newWidget.replace(/__name__/g, collectionCount);
collectionCount++;
var newTr = jQuery('<tr></tr>').html(newWidget);
newTr.appendTo(collectionList);
});
$('.remove-collection').click(function (e) {
console.log('fdsffdsfds');
e.preventDefault();
$(this).parent().remove();
return false;
});
})
I put a console.log to check if a I am going through there but Not.
This is the button:
<button type="button" class="btn btn-danger remove-collection">Delete</button>