Search code examples
javascripthtmlcssbootstrap-5tooltipster

Using Tooltipster with ClipboardJS, problem loading tooltips on click


I have in my project Bootstrap5, ClipboardJS, JQuery and Tooltipster.

I have tried to follow exactly the initial instructions on the Tooltipster website, I could not figure out what I missed, here are two captions, the first of the JavaScript scripts and the other of one the components (buttons) where a tooltip should appear after clicking one of them:


<!-- (Right before </body>) -->

<!-- ClipboardJS -->

<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.10/clipboard.min.js"></script>

<script>
    var btns = document.querySelectorAll('.btn');
    var clipboard = new ClipboardJS(btns);
</script>

<!-- Tooltipster -->

<script type="text/javascript" src="tooltipster.bundle.min.js"></script>
<script>
    $(document).ready(function() {
        $('.btn').tooltipster({
            trigger: 'click'
        });
    });
</script>

<!-- JQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>

<!-- Bootstrap -->


<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
                    <button class="btn btn-outline-dark rounded ms-2" title="Copied!  🙌" type="button" data-clipboard-target="#email">
                        Copy
                    </button>

Thank you for help.


Solution

  • I had to load JQuery before Tooltipster as Marc said in a comment, I was not aware it matters.