Jquery x-editable doesnt work - Laravel 6.x

222 Views Asked by At

Have this application in Laravel 6 and trying to add x-editable to a list of Event Subscribers, so I can edit this subscribers registers without redirect to another page/route, using only x-editable inline and Ajax to update the data. But I'm generating this modal list using Ajax.

Here's javascript code:

<script>
$('.openModal').on('click', function(){
  
    var id = $(this).data('id');
    var table = $("#subscribers");
    table.html('');

    $.ajax({
        type: 'GET',
        url: '/participantes/' + id,
        success: function(data){
            $("#subscribersModal").modal("show");
            table.append('<tr><th>' + "Nome" + '</th><th>' + "Email" + '</th><th>' + "Ações" + '</th></tr>');
            data.forEach(function(row){
                var isGenerated = row.certified_generated === 1 ? '<span class="badge badge-success">Gerado</span>' : '<span class="badge badge-danger">Não gerado</span>';
                var isValidated = row.already_validation_code !== null ? '<span class="badge badge-info">Validado</span>' : '<span class="badge badge-danger">Não validado</span>';
                var generateButton = row.certified_generated === 1 ?  '' : '<button class="btn generate-sub" title="Gerar certificado"><i class="fa fa-refresh" aria-hidden="true"></i></button>';
                var editUrl = '{{route("evento.update-participante", ":id") }}';
                editUrl = editUrl.replace(':id', row.id);
                table.append('<tr><td><a class="xedit" data-type="text" data-pk="'+ row.id + '" data-title="Edit">' + row.name + '</a><br>' + isGenerated +  isValidated + '</td><td>' + row.email + '</td><td>'+ '<a href="'+ editUrl +'" title="Editar registro"><i class="fa fa-pencil" aria-hidden="true"></i></a>' + generateButton + '</td></tr>');
            });
        }
    })
});

Javascript code x-editable

<script>
    $.fn.editable.defaults.mode = 'inline';

    $(document).ready(function() {
    $('.xedit').editable();
    });
</script>

First I tought that was an import js/css CDN problem, but then I test with the data coming directly from the blade engine and work as well.

I dont have any idea why this is hapenning, someone could help?

0

There are 0 best solutions below