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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:43:13+00:00 2026-05-28T17:43:13+00:00

I have a jquery widget like this: $.widget(ui.MyWidget, { options: { Value1: 10, Value1:

  • 0

I have a jquery widget like this:

$.widget("ui.MyWidget", {
              options: {            
            Value1: 10,
            Value1: 20,
        },
// and other methods like _create,...
});

And, i am extending it like this:

$.widget("ui.MyExtWidget", $.extend({
            options: {
            Value3: 20,
        }}, $.ui.MyWidget.prototype, {
        myNewMethod: function(){
            alert(this.options.Value1+this.options.Value3);
        }
}

I have to call the “myNewMethod” in my html.

My html code is like this:

$("#Div1").MyExtWidget();
$("#Div1").MyExtWidget("myNewMethod");

I am getting exception like this while using the above code cannot call methods on TimeSpanHeader prior to initialization; attempted to call method ‘myNewMethod’

What is the way to call the “myNewMethod” method?

  • 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-28T17:43:14+00:00Added an answer on May 28, 2026 at 5:43 pm

    The widget factory provides a way to extend from an existing widget with $.widget constructor:

    $.widget("ui.MyExtWidget", $.ui.MyWidget, {
        options: {
            alertText: ''
        },
        myNewMethod: function() {
            alert('Value1 = ' + this.options.Value1);
            alert('alertText = ' + this.options.alertText);
        }
    });
    

    Note: The constructor will take care of extending the options as well. This is the method used in the jQuery UI library itself. For instance, the widget ui.mouse has options and a lot of the other widgets inherits from it and have their own extra options along with the ones from ui.mouse.

    DEMO


    From the Widget Factory wiki post:

    The widget factory is a simple function on the global jQuery object –
    jQuery.widget – that accepts 2 or 3 arguments.

    jQuery.widget(“namespace.widgetname”, /* optional – an existing widget prototype to inherit from /, / An object literal to become the widget’s prototype*/ {…} );

    The second (optional) argument is a widget prototype to inherit from.
    For instance, jQuery UI has a “mouse” plugin on which the rest of the
    interaction plugins are based. In order to achieve this, draggable,
    droppable, etc. all inherit from the mouse plugin like so:
    jQuery.widget( “ui.draggable”, $.ui.mouse, {…} ); If you do not
    supply this argument, the widget will inherit directly from the “base
    widget,” jQuery.Widget (note the difference between lowercase “w”
    jQuery.widget and uppercase “W” jQuery.Widget).

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

Sidebar

Related Questions

I have a jquery ui widget defined like this: $.widget(ui.someWidget, options: {}, _create =
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
Say I have jquery code like this: html += '<div class=index>' + item.index +
This is the scenario: I'm developing a dropdown widget in Jquery. I have to
I'm using JQuery UI's autocomplete widget and would like to have access to the
I have a form like this: <form class=category_form id=category_form method=post> <p class=ui-widget> <label for=birds>Birds:
I have added a method on jQuery validator like this $.validator.addMethod( 'myEqual', function (value,
I have a code like this one: $('div.widgetDroppable').droppable({ accept: 'li.widget', drop: function(event, ui) {
I have Jquery and CSS tab like this one and in the each tab
I have followed this tutorial which uses jQuery UI to generate Facebook tokens like:

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.