Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit Button not firing up the modal #9

Open
cfox4ever opened this issue Feb 3, 2023 · 1 comment
Open

Edit Button not firing up the modal #9

cfox4ever opened this issue Feb 3, 2023 · 1 comment

Comments

@cfox4ever
Copy link

cfox4ever commented Feb 3, 2023

 <td>
        <button class="btn btn-primary btn-sm" hx-get="{% url 'edit_branch' branch.id %}" hx-target="#dialog">Edit
      <li class="fa fa-edit"></li>
    </button>

        <a href="" class="btn btn-warning btn-sm">
            <li class="fa fa-eye"></li>

        </a>
    </td>


;
(function() {
    const modal = new bootstrap.Modal(document.getElementById("modal"))

    htmx.on("htmx:afterSwap", (e) => {
        // Response targeting #dialog => show the modal
        console.log("xxxxxxxxx")
        if (e.detail.target.id == "dialog") {
            modal.show()
        }
    })

    htmx.on("htmx:beforeSwap", (e) => {
        // Empty response targeting #dialog => hide the modal
        if (e.detail.target.id == "dialog" && !e.detail.xhr.response) {
            modal.hide()
            e.detail.shouldSwap = false
        }
    })

    // Remove dialog content after hiding
    htmx.on("hidden.bs.modal", () => {
        document.getElementById("dialog").innerHTML = ""
    })
})()
@RmaxTwice
Copy link

This could be an issue with the django side of the implementation, if the request the edit button fires ends up in a 500 error or doesn't return any content then the modal will never open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants