calebjacob / tooltipster

A jQuery tooltip plugin
MIT License
2.76k stars 480 forks source link

delay works only on repeated hovers #749

Closed psprokofiev closed 5 years ago

psprokofiev commented 6 years ago

If I hover the mouse on element the first time - tooltipster loads immediately, if I hover again - it loads after delay. I need that delay is at each hover, also at first time.

$('body').on('mouseenter', '.hovercard:not(.tooltipstered)', function() {
        $(this).tooltipster({
            theme: 'tooltipster-shadow',
            zIndex: 1055,
            contentAsHTML: true,
            interactive: true,
            minWidth: 320,
            delay: [ 3000, 0 ],
            content: 'Loading...',
            functionBefore: function(instance, helper) {
                var $origin = $(helper.origin),
                    card = $origin.data('card'),
                    model = $origin.data('model'),
                    id = $origin.data('id');
                if ($origin.data('loaded') !== true) {
                    var route = [ '/hovercard', card, model, id ].join('/');
                    axios.get(route)
                        .then(function (response) {
                            instance.content(response.data);
                        })
                        .catch(function (error) {
                            instance.content('Not loaded');
                            console.warn(error, instance);
                        })
                        .then(function () {
                            $origin.data('loaded', true);
                        });
                }
            }
        })
        .tooltipster('open');
    });
psprokofiev commented 6 years ago

This bug is only in this "case":

$('body').on('mouseenter', '.hovercard:not(.tooltipstered)', function() {
        $(this).tooltipster({

in this code all is ok:

$('.hovercard').tooltipster({
        delay: [ 3000, 0 ],
louisameline commented 5 years ago

Please check the FAQ about delegation. Thank you