Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8533157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:53:41+00:00 2026-06-11T09:53:41+00:00

I need to know what I am doing wrong because I cannot call the

  • 0

I need to know what I am doing wrong because I cannot call the internal functions show or hide?

(function()
{
    var Fresh = {
        notify:function()
        {
            var timeout = 20000;
            $("#notify-container div").get(0).id.substr(7,1) == "1" && (show(),setTimeout(hide(),timeout));
            var show = function ()
            {
                $("body").animate({marginTop: "2.5em"}, "fast", "linear");
                $("#notify-container div:eq(0)").fadeIn("slow");
            },
            hide = function()
            {
               $("#notify-container div").hide();
            }
        }//END notify
    }
    window.Fresh = Fresh;
})();
Fresh.notify();

thanks, Richard

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:53:42+00:00Added an answer on June 11, 2026 at 9:53 am

    UPDATE

    If you wanted to be able to do something like: Fresh.notify.showMessage(), all you need to do is assign a property to the function notify:

    var Fresh = {notify:function(){return 'notify called';}};
    Fresh.notify.showMessage = function () { return this() + ' and showMessage, too!';};
    Fresh.notify();//notify called
    Fresh.notify.showMessage();//notify called and showMessage, too!
    

    This will point to the function object here, and can be called as such (this() === Fresh.notify();). That’s all there is too it.

    There’s a number of issues with this code. First of all: it’s great that you’re trying to use closures. But you’re not using them to the fullest, if you don’t mind my saying. For example: the notify method is packed with function declarations and jQuery selectors. This means that each time the method is invoked, new function objects will be created and the selectors will cause the dom to be searched time and time again. It’s better to just keep the functions and the dom elements referenced in the closure scope:

    (function()
    {
        var body = $("body");
        var notifyDiv = $("#notify-container div")[0];
        var notifyDivEq0 = $("#notify-container div:eq(0)");
        var show = function ()
        {
            body.animate({marginTop: "2.5em"}, "fast", "linear");
            notifyDivEq0.fadeIn("slow");
        };
        var hide = function()
        {//notifyDiv is not a jQ object, just pass it to jQ again:
            $(notifyDiv).hide();
        };
        var timeout = 20000;
        var Fresh = {
            notify:function()
            {
                //this doesn't really make sense to me...
                //notifyDiv.id.substr(7,1) == "1" && (show(),setTimeout(hide,timeout));
                //I think this is what you want:
                if (notifyDiv.id.charAt(6) === '1')
                {
                    show();
                    setTimeout(hide,timeout);//pass function reference
                    //setTimeout(hide(),timeout); calls return value of hide, which is undefined here
                }
            }//END notify
        }
        window.Fresh = Fresh;
    })();
    Fresh.notify();
    

    It’s hard to make suggestions in this case, though because, on its own, this code doesn’t really make much sense. I’d suggest you set up a fiddle so we can see the code at work (or see the code fail :P)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to know what am I doing wrong, because the generated query doesn't
Hello Am Currently Doing An App Related To Sound Modulation I need to know
I am doing a project, for which I need to know all the wikipedia
I'm doing some attribute parsing as a string, so I need to know how
I'm doing some work with registry hives, and I need to know if the
Hi i am doing a small project in C#, and i need to know
does anyone know of a good way of doing the following, I need to
Need to know this so that i could send DTMF and that is going
Need to know which event triggered after text selection done in Apple iPad. It
I need to know how to change background of expanded list item when it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.