Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

637
Visualizações
Laravel modal component dont work via back-end render code

I have a laravel modal component which is called via data-modal-toggle attribute. The problem is when I create the button from the backend (via Yajra datatables), It wont work but the other button which has a data-modal-toggle in the blade works fine. Any idea how can i render the said modal?

Here is the code from my backend

        return Datatables::of($apparatus)
            ->addIndexColumn()
            ->addColumn('buttons', function ($row) {
                return '<button type="button" data-modal-toggle="modal-add-app" class="grantors-btn rounded-full font-bold bg-indigo-500 px-4 py-2 text-white">Edit</button>';
            })
            ->rawColumns(['buttons'])
            ->make(true);

As you can see my button has data-modal-toggle attribute but when i click it the component wont show.

But in my blade I tried to have some button that has also the same attribute and calling the same modal component and it works

<button type="button" data-modal-toggle="modal-add-app" class="grantors-btn rounded-full font-bold bg-indigo-500 px-4 py-2 text-white">Add Apparatus</button>

If possible. I want to call the modal via js function

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

The button could call a function to show the modal. This what I used:

<td>
    <button class="btn btn-sm btn-link" @click.prevent="showModal()">
         <i class="fas fa-edit text-warning">
    </button>
</td>

And the function to show the modal as below:

showModal() {
        $('#exampleModal').modal('show'); 
 },
about 4 years ago · Juan Pablo Isaza Relatório

0

I had the same problem just add $(document).ready() inside it type you javascript code to open the modal

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda