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

  • Home
  • SEARCH
  • 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 8605133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:45:00+00:00 2026-06-12T02:45:00+00:00

How do I extend an existing object method in jQuery? For instance, I’m using

  • 0

How do I extend an existing object method in jQuery?

For instance, I’m using jqBarGraph. Now I want to add an addGrid() function to it. I was thinking I’d do it like so:

(function($) {
  $.fn.jqBarGraph.addGrid = function(){
    var o = this;
    // do something with 'o'
    return o;
  }
})(jQuery);

…but when I call $('#chart').jqBarGraph(options).addGrid(); — I get the error:

Uncaught TypeError: Cannot call method 'addGrid' of undefined

  • 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-12T02:45:01+00:00Added an answer on June 12, 2026 at 2:45 am

    You’re adding a property to the function, so you can really only access it as e.g.

    $('#chart').jqBarGraph.addGrid();
    

    which is not what you want. It seems like jqBarGraph does not return anything when called. You’d have to patch the function yourself like this:

    (function(old) {
      $.fn.jqBarGraph = function() {
        old.apply(this, arguments);  // call the actual function
    
        // return something
        return {
          addGraph: function() { ... }
        };
      };
    
      $.fn.jqBarGraph.defaults = old.defaults;  // restore properties
    })($.fn.jqBarGraph);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Javascript, you can extend existing classes by using its prototype object: String.prototype.getFirstLetter =
I'm using Sencha touch 2. I have store that load from existing js object:
I'm wondering if you can extend already existing enumerations in Scala. For example: object
I want create a new JavaScript object based on an existing JavaScript object. Till
I would like to extend the existing XMLHttpRequest object so that it should work
I am digging into Twitter's Bootstrap and now want to try and add some
I find them a very natural way to extend existing classes, especially when you
Im trying to extend an existing program to include sub directorys, It gets the
I have to extend an existing applet by adding it the ability to write
I have a college project where I need to extend an existing spreadsheet application

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.