dezman
dezman

Reputation: 19388

Code only executes once but should continue

The code below should prevent the popup from closing if you mouseover it, or the button, however, it only works once on reload and then stops working.

$('.popover3-test').popover({
    placement:'bottom',
    template: $('.popover2'),
    trigger: 'manual',

    }).mouseenter(function(e) {
    $(this).popover('show');

    var t = null;

    $(".popover2, .popover3-test")
        .mouseleave(function() {
            t = setTimeout(function() {
                $('.popover2').hide();
            }, 1000); // Or however many milliseconds
        })
        .mouseenter(function() {
            if(t !== null)
                clearTimeout(t);
         });
    });

Demo: http://jsfiddle.net/MnpWV/1/

Upvotes: 0

Views: 90

Answers (1)

Ram
Ram

Reputation: 144729

try this:

$(".popover2, .popover3-test")
        .mouseleave(function() {
           $('.popover2').delay(1000).fadeOut('1000');
        }
});

http://jsfiddle.net/MnpWV/8/

update:

$(".popover2").hover(function(e) {
    $(this).show()
}, function() {
    $('this').delay(1000).fadeOut('1000');
})

http://jsfiddle.net/MnpWV/16/

remove the .popover3-test which triggers the mouseleave event.

Upvotes: 1

Related Questions