Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript [Solved] Window.[function name] not defined

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #178676
    matthisco
    Participant

    Hi,

    I have a jquery dialog in a closure which I am trying to fire in my code, Keep getting the error:

    Error: TypeError: window.xxx.Alert is not a function

    Can anyone please help?

    
    $( ".terms" ).click(function() {
          Alert('test');
    });
    

    Here is my script

    
    /*global window*/
    /*global $ */
    
    window.xxx= window.xxx|| {};
    window.xxx.Alerter = (function () {
    
        'use strict';
    
        var alerter, confirm;
    
        alerter = function (passit, title, onclose, url) {
    
            $("#dialog-default > p").text(String(passit));
    
            if (title !== undefined) {
                $("#dialog-default").attr('title', title);
    
            } else {
                $("#dialog-default").attr('title', 'Warning');
            }
    
            $("#dialog-default").dialog({
                open: function () {
                    $(".ui-state-focus").blur();
    
                     $(this).load('/index.php');
                },
                modal:true,
                buttons: {
                    "Close": function () {
                        $(this).dialog("close");
                        if (onclose !== undefined) {
                            onclose();
                        }
                    }
                }
            });
        };
        confirm = function (message, title, onconfirm, oncancel) {
    
            var response = false;
    
            $("#dialog-default > p").text(String(message));
            if (title !== undefined) {
                $("#dialog-default").attr('title', title);
            } else {
    
                $("#dialog-default").attr('title', 'Confirmation');
            }
    
            $("#dialog-default").dialog({
                open: function () {
                    $(".ui-state-focus").blur();
    
                },
                buttons: {
                    "OK": function () {
                        $(this).dialog("close");
    
                        if (onconfirm !== undefined && onconfirm !== null) {
                            onconfirm();
                        }
    
                        response = true;
                    },
                    "Cancel": function () {
                        $(this).dialog("close");
    
                        if (oncancel !== undefined && oncancel !== null) {
                            oncancel();
                        }
    
                        response = false;
                    }
                }
            });
            return response;
    
        };
    
        return {
            Alert: alerter,
            Confirm: confirm
        };
    }());
    
    
    #178681
    Paulie_D
    Member

    I’m a complete JS Novice…but shouldn’t it be alert rather than Alert…but then what do I know?

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.