On load rather than on click

Posted by connor on Stack Overflow See other posts from Stack Overflow or by connor
Published on 2012-08-19T12:27:07Z Indexed on 2012/09/18 3:38 UTC
Read the original article Hit count: 131

Filed under:
|
|
|

I have the following code:

jQuery(function ($) {
    var OSX = {
        container: null,
        init: function () {
            $("input.apply, a.apply").click(function (e) {
                e.preventDefault(); 

                $("#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
                });
            });
        },
        open: function (d) {
            var self = this;
            self.container = d.container[0];
            d.overlay.fadeIn('fast', function () {
                $("#osx-modal-content", self.container).show();
                var title = $("#osx-modal-title", self.container);
                title.show();
                d.container.slideDown('fast', function () {
                    setTimeout(function () {
                        var h = $("#osx-modal-data", self.container).height()
                            + title.height()
                            + 20; // padding
                        d.container.animate(
                            {height: h}, 
                            200,
                            function () {
                                $("div.close", self.container).show();
                                $("#osx-modal-data", self.container).show();
                            }
                        );
                    }, 300);
                });
            })
        },
        close: function (d) {
            var self = this; // this = SimpleModal object
            d.container.animate(
                {top:"-" + (d.container.height() + 20)},
                500,
                function () {
                    self.close(); // or $.modal.close();
                }
            );
        }
    };

    OSX.init();

});

To load this script, a button with the class "apply" has to be clicked... Does anyone know a way of loading this script "onload" without a button being clicked?

I have tried a lot of things, but I am a newbie when it comes to Javascript.

Thanks!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about script