Rocky
Rocky

Reputation: 73

jQuery SimpleModal plugin - open onLoad

I want to use the SimpleModal Confirm Override functionality and modify it so it is activated onLoad of a page.

Can someone please assist?

Link to the SimpleModal demos page website.

Upvotes: 1

Views: 6192

Answers (3)

Ytters Arnel
Ytters Arnel

Reputation: 1

Open the osx.js and remove the following line (the code start at line 14)

        init: function () {
        ****$("input.osx, a.osx").click(function (e) { << delete this line
            e.preventDefault();**** << delete this line

            $("#osx-modal-content").modal({
                overlayId: 'osx-overlay',
                containerId: 'osx-container',
                closeHTML: null,
                minHeight: 80,
                opacity: 65, 
                position: ['0',],
                overlayClose: true,
                onOpen: OSX.open,
                onClose: OSX.close
            });
        }); <<< delete this line
    },

to become

        init: function () {

            $("#osx-modal-content").modal({
                overlayId: 'osx-overlay',
                containerId: 'osx-container',
                closeHTML: null,
                minHeight: 80,
                opacity: 65, 
                position: ['0',],
                overlayClose: true,
                onOpen: OSX.open,
                onClose: OSX.close
            });

    },

Upvotes: 0

Eric Martin
Eric Martin

Reputation: 2841

Open confirm.js and change:

jQuery(function ($) {
    $('#confirm-dialog input.confirm, #confirm-dialog a.confirm').click(function (e) {
        e.preventDefault();

        // example of calling the confirm function
        // you must use a callback function to perform the "yes" action
        confirm("Continue to the SimpleModal Project page?", function () {
            window.location.href = 'http://www.ericmmartin.com/projects/simplemodal/';
        });
    });
});

To:

jQuery(function ($) {
    // example of calling the confirm function
    // you must use a callback function to perform the "yes" action
    confirm("Continue to the SimpleModal Project page?", function () {
        window.location.href = 'http://www.ericmmartin.com/projects/simplemodal/';
    });
});

Upvotes: 0

James Kovacs
James Kovacs

Reputation: 11661

This would display the modal dialog on page load...

$(document).ready(function() { 
    $('#basicModalContent').modal();
});

Upvotes: 3

Related Questions