ToolTip plugin

0

Cześć,
Tworzę bardzo prosty plugin do wyświetlania tooltip i utknąłem. Konsola wywala mi błąd Uncaught TypeError: this._init is not a function (linia 25).
Kod:

(function () {
    "use strict";

    const elem = document.querySelectorAll("[data-toggle='tooltip']");

    elem.forEach(function (item, index) {
        var div = document.createElement("div");
        div.setAttribute("id", "tooltip_" + index);

        var tooltip = new _jsToolTip(div, item.getAttribute("title"), true);

        item.addEventListener("mouseenter", function (e) {
            tooltip.show();
        });

        item.addEventListener("mouseleave", function (e) {
            tooltip.destroy();
        });

    });

    function _jsToolTip(element, text, arrow) {
        this.tooltip = element;

        this._init(text, arrow);
    }

    _jsToolTip.prototype = {
        _init: function (text, arrow) {
            this.tooltip.classList.add("tooltip");

            if (arrow)
                this.tooltip.classList.add("arrow");

            this.tooltip.innerHTML = text;
        },
        show: function () {
            document.body.appendChild(this.tooltip);
        },
        destroy: function () {
            this.tooltip.remove();
        }
    };
})();
0

Dobra już mam - dureń ze mnie kolejność - wywołuję coś co nie zostało jeszcze wczytane...

1 użytkowników online, w tym zalogowanych: 0, gości: 1