Hi @evstevemd
I’ve seen the post you shared with me, but it does not work such as I thought.
In my code, I have the delete-modal with ok-cancel options, inside the same index file.
and confirmation action is in another file called index.js
inside here I fill the body message of the confirmation modal, and reload Pjax container.
Is there any way to reload those buttons while items are deleted? That Could be work
It is hard for me to guess what you thought. The best way is incorporate the code in your code and then ask about exact part that is missing with new example code
yes. Item is deleted and also table widget (this already were working), so nothing has changes.
console no returns error messages
after delete item, I proceed to delete the next, and and modal no loads (without error messages).
If you need more info, code, please ask me
This won’t work for the 2nd time, because the delete buttons with class="btn-eliminar-compentencia" have been overwritten by the 1st PJAX call and have lost the event handler.
The solution is to attach the event handler to an ancestor DOM object outside the PJAX updated area.
You may change $('#pjax-container') to $('body') or anything that is an ancestor of the delete buttons and is outside the PJAX area. In this way, the click events of the delete buttons will be handled by the PJAX-free event handler attached to the ancestor.
I understand the idea, but I can’t get to the solution.
I only did this change and I don’t have the expected results. surely something is wrong with my code,.
The selector '.btn-modal-eliminar-competencia' refers to a button inside the modal, and it is not in the PJAX area. You don’t have to touch it. Or, exactily saying, you can not attach an event handler of this button to $(#pjax-container), because it is not a descendant of $('#pjax-container').
I did the modification, and now the modal confirmation button no has action. If is clicked, don’t do any action. so don’t make the item delete.
something is missing, but I don’t know what is.
I’m sorry for disappointing you, but I’ve returned to the beginning.
Item is deleted, page no refresh, try to delete a second item. modal no load.
This is my current code with your tips and modifications suggested. I’ve incorporated the controller method, and code when the modal is closed.
index view https://codeshare.io/OdYRy7
This may not be the best solution but it seems to work
Problem: click_1() is called twice on first click, only once thereafter.
Solution: Add the click() handler but don’t call click_1().