Klaaz
Klaaz

Reputation: 1640

simplemodal autoclose after delay

I'd like to do this:

$.modal("<div><h1>SimpleModal</h1></div>").delay(500).close();

I also like to close the modal div when clicking anywhere on the screen, so it is not really modal ;-)

But daisychaining appears to be not working. How to solve this?

Upvotes: 0

Views: 1769

Answers (2)

dfsq
dfsq

Reputation: 193271

This will work:

$.modal('<div><h1>SimpleModal</h1></div>', {
    overlayClose: true,
    onShow: function() {
        setTimeout($.modal.close, 500);
    }
})

Update

$.modal('<div>HELLO</div>', {
    overlayClose: true,
    onShow: function() {
        var timer;
        $('#simplemodal-container').bind({
            mouseenter: function() {
                clearTimeout(timer);
            },
            mouseleave: function() {
                timer = setTimeout($.modal.close, 1500);
            }
        })
        .trigger('mouseleave');
    }
});

Upvotes: 1

davidethell
davidethell

Reputation: 12018

I haven't tested this, but did you try something like this?

var $modal = $.modal("<div><h1>SimpleModal</h1></div>").delay(500).close();
$('body').not($modal).click(function() {
    $modal.close();
});

Upvotes: 0

Related Questions