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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:51:35+00:00 2026-06-03T23:51:35+00:00

Looks like this question is popular, but there is no jQuery version. I have

  • 0

Looks like this question is popular, but there is no jQuery version.

I have two classes the second is extended from the first one.

The extension method is copied from here.

function UIButton(o){
    if (typeof(o) != 'undefined') $.extend(true, this, o); 
    this.setOutput=function(divname){
      alert("first");
    }
}

function UIButton2(o) {
    if (typeof(o) != 'undefined') $.extend(true, this, o);
    this.setOutput=function(divname) {
        alert("second");
    }
    return new UIButton(this);
}

According to the jquery documentation

The second object’s method should override the first object’s method (with same name) by using $.extend().

However I check it in the html and found the first object’s function still work like good. (Alert “first”…) This makes its subclass cannot override the function.

So I want to ask, how this happen and how to solve it. I want to alert “second”……

  • 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-03T23:51:36+00:00Added an answer on June 3, 2026 at 11:51 pm

    You extend first, and then you set the new setOutput (so you overwrite the extended method).

    If you change the order it will work..

    function UIButton(o){
        this.setOutput=function(divname){
          alert("first");
        }
        if (typeof(o) != 'undefined') $.extend(true, this, o); 
    }
    
    function UIButton2(o) {
        this.setOutput=function(divname) {
            alert("second");
        }
    
        if (typeof(o) != 'undefined') $.extend(true, this, o);
        return new UIButton(this);
    }
    

    (only needed in the UIButton for this example, but i added it to both for future usage)

    Demo at http://jsfiddle.net/gaby/R26ec/

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

Sidebar

Related Questions

Absolute beginner question: I have a template file index.html that looks like this: ...
Quick question... I have a query that checks for duplicates that looks like this:
Noob question here! I have an array with hashes that looks like this: arr
Not even how to word this question: I have a table that looks like
It looks like this question is pretty simple but I can't find the clear
It looks like this question was addressed here , but his solution did not
This question looks like this one : Programmatically binding List to ListBox but as
I have been searching around and it looks like this question has been asked
I have an HTML page that for the sake of this question looks like
Okay guess this question looks a lot like: What is the best way to

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.