Search code examples
jquerymodal-dialogpopupsimplemodal

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.


Solution

  • 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/';
        });
    });