In this following block
$(document).on('turbolinks:load', function() {
$('[data-js-usercontent-form]').on("ajax:success", function(event, data, status, xhr){
var usercontent = $(xhr.responseText).hide();
$('#usercontents').append(usercontent);
usercontent.fadeIn(1000);
document.getElementById('data-js-usercontent-form').reset();
});
$('[data-js-usercontent-id]').on("ajax:success", function(event, data, status, xhr){
var usercontent_id = xhr.responseJSON.id;
$('[data-js-usercontent-id=' + usercontent_id + ']').hide();
});
});
One creates a usercontent and it will appear via the fadeIn.
One can delete a usercontent and it will be hidden. Well, in some cases.
The deletion works on a usercontent already created at time of page rendering, as the javascript has the usercontent_id
to hide within the page code...
If a record is created and shown via AJAX, said record cannot be deleted until the page is refreshed.
Is there a solution to this situation (aside from page refresh)?