JavaScript onClick event does not work with data-modal - Asp.Net Core MVC

0

I have a DataTable in my Index in which lines are loaded using JavaScript. The Edit, Details, Delete, and History buttons are created together. All of them open in a modal window (the modal block is inside the Index) ... In the html of each button there is a "data-modal" tag in which it will serve as reference for the onclick event that will cause that button to open in the Modal window.

"columns": [
            { "data": "id", "name": "Id", "autoWidth": true },
            { "data": "descricao", "name": "Descricao", "autoWidth": true },
            { "data": "pessoaTipoDescricao", "name": "PessoaTipo", "autoWidth": true },
            {
              
                "render": function (data, type, full, meta) {
                    return '<a btnEditar title="Editar" data-modal="" href="/situacoes-gerenciamento/editar-situacao/' + full.id + '" class="btn btn-sm btn-icon btn-pure btn-default on-default edit-row"><span class="icon-2x wb-edit"></span></a> |' +
                           '<a title="Detalhes" data-modal="" href="/situacoes-gerenciamento/situacao-detalhes/' + full.id + '" class="btn btn-sm btn-icon btn-pure btn-default on-default footable-row-detail-row"><span class="icon-2x wb-search"></span></a> |' +
                           '<a title="Excluir" asp-action="Delete" data-modal="" class="btn btn-sm btn-icon btn-pure btn-default on-default remove-row"><span class="icon-2x wb-trash"></span></a> |' +
                           '<a title="Histórico" class="btn btn-sm btn-icon btn-pure btn-default on-default clockpicker" data-toggle="modal" data-target="#pessoaHistory" data-original-title="Histórico"><span class="icon-2x wb-time"></span></a>'
                }
            }
        ],

Problem: Clicking the "Edit" button does not recognize the "data-model" tag and the onclick event is not working:

 $('a[data-modal]').on('click', function (e) {
        // Abre a janela modal com o formulário solicitado 
        openmodal(this.href);
        return false;
    });

Does anyone know how to solve this?

    
asked by anonymous 09.06.2018 / 13:21

1 answer

0

A ] is missing in $('a[data-modal')

    
09.06.2018 / 14:17