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 7829025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:35:11+00:00 2026-06-02T10:35:11+00:00

Here I attempted to create a package called com.matogen.ght with a class in it,

  • 0

Here I attempted to create a package called com.matogen.ght with a class in it, Calendar. I’d like the init() method to be called automatically when I instantiate the calendar object. The example below works, but I still have to explicitly call the init() method.

var com = {
    matogen : {
        ght : {
            'Calendar' : function() {       

                this.init = function() {
                    console.log("This is my constructor");
                }

            }
        }
    } 
}

$(document).ready(function() {
    var cal = new com.matogen.ght.Calendar();
    cal.init();

});
  • 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-02T10:35:12+00:00Added an answer on June 2, 2026 at 10:35 am

    just change your init function like so

    this.init = (function() {
        console.log("This is my constructor");
    }());
    

    with a self executed anonymous function or, if you prefer, just call the function itself like so

    ...
        Calendar : function() {       
    
            this.init = function() {
                console.log("This is my constructor");
            };
            this.init();
        }
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have attempted to create my own UITypeEditor but the EditValue method never gets
I'm after a simple stored procedure to drop tables. Here's my first attempt: CREATE
I am attempted to create a new Sales Order in Netsuite using PHPtoolkip_v2010.php and
I am asked to create a Substring() method that returns a substring of the
So I installed the new MVC3 tooling update and attempted to create a new
I'm using the android version of cocos2d located here: https://github.com/ZhouWeikuan/cocos2d I'm an iPhone guy
Using this previous question as a guide, I've attempted to create a ul navigation
I must have missed something here. I am trying to create a table but
Here is my attempt in jquery that kind of works but something is going
How to dynamically change the timeout of the cycle plugin here is my attempt

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.