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
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');
},
I had the same problem just add $(document).ready() inside it type you javascript code to open the modal