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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:42:19+00:00 2026-05-26T08:42:19+00:00

I am trying to set up library like jQuery simply for learning purposes. I

  • 0

I am trying to set up library like jQuery simply for learning purposes. I have it working decently well, and I can do method chaining as needed. The problem I am having is being able to call a method with the class’ parenthesis:

What I have to do:

$foo().get('id1');

What I would like to do:

$foo.get('id1');

Here is the current javascript:

(function( window ) {
    var document = window.document;
    var fooTools = (function() {
        var fooTools = function( selector ) {
            return new fooTools.base.init( selector );
        };

        fooTools.base = fooTools.prototype = {
            init: function( selector ) {
                if( !selector ) {
                    return this;
                } 
                if( selector ) {
                    this[0] = selector;
                        this.length = 1;
                        return this;
                }
            },

            get: function( id ) {
                return document.getElementById( id );
            },

            //..other methods

        };       
        fooTools.base.init.prototype = fooTools.base;
        return fooTools;    
    }());
    window.fooTools = window.$foo = fooTools;
}( window ));

Currently it works just fine, but if I do not include the parenthesis I get an error that the .get() method does not exist. I still want to maintain the ability to use parenthesis for other methods, so i just want it be optional. Thanks!

  • 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-05-26T08:42:20+00:00Added an answer on May 26, 2026 at 8:42 am

    change:

    window.fooTools = window.$foo = fooTools;
    

    to:

    window.$foo = new fooTools();
    window.fooTools = fooTools;
    

    Live Example


    EDIT

    window.fooTools = fooTools;
    window.$foo= fooTools;
    window.$foo.get = fooTools.prototype.get;
    

    Updated Example

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

Sidebar

Related Questions

I'm trying to set up autoconf for my project. I have everything working properly
I'm trying to put together a String in a tag-library like this: <c:set var=columnText
I'm working on a set of web services and we'd like to have a
Setup I have a graph library where I am trying to decompose things as
I'm trying to create a set of function templates that can take different types
I'm trying to set up a third party library's signing tool as an external
Well I'm trying to set a variable to use in a thread, it works
I'm trying to send an e-mail with Codeigniter like this: $this->load->library('email'); $this->email->from(myemail@email.com); $this->email->reply_to(myemail@email.com); $this->email->to(myemail@email.com);
Im trying set the single table inheritance model type in a form. So i
I am trying set up databinding as described in the title. The problem I

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.