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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:11:50+00:00 2026-05-31T19:11:50+00:00

I am learning jQuery UI. I downloaded a code in which the author made

  • 0

I am learning jQuery UI. I downloaded a code in which the author made a plugin. Code is working but i am confusing when author is calling a function. Here is the code

(function($){

    $.widget("ui.calculator", {

        options: {

            autoShow: true,
            currentSum: []

        }, //end of options

        _create: function(){..},
        destroy: function(){..},
        disable: function(){..},
        enable: function() {..},
        show: function() {
            var el = this.element.children(":first");
            if (el.is(":hidden")) {
                el.show();
            }
            this._trigger("show", null, this.element);
        }, //end of show()

         _addHoverState: function(){..}, 
         ..
    }); //end of $.widget()

})(jQuery);

and here it is calling the method

$(document).ready(function(){

    //To configure the autoShow option, we could use:
    //To add a handler for the custom show event we defined     
    $("#calc").calculator({
        autoShow: true,
        show: function(e, ui) {
            alert(e + ", " + $(ui).attr("id"));
        }
     });

 }); //end of document.ready(fn)

I am confusing in calling. I define show method just show: function(){} no argument i am passing. But when calling i am writing show: function(e, ui) {} passing two arguments to my show function. Why? Also i debug it in the firebug and i noticed that after show: function(e, ui) { line, it comes to _create() method of the plugin , but don’t go inside show method. Why?
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-31T19:11:51+00:00Added an answer on May 31, 2026 at 7:11 pm

    You have two entirely different shows. This one:

    $("#calc").calculator({
        show: function(e, ui) { /* ... */ }
    });
    

    is a callback function that your calculator widget calls. Somewhere inside your widget you’d say:

    this.options.show.call(some_sensible_this, e, ui);
    

    to call it with whatever context (some_sensible_this) makes sense for your widget or if you don’t care about the context, you’d just say:

    this.options.show(e, ui);
    

    The show that you define with the widget factory:

    show: function() {
        var el = this.element.children(":first");
        if (el.is(":hidden")) {
            el.show();
        }
        this._trigger("show", null, this.element);
    }
    

    will be a jQuery-UI style method on your widget that you’d call like this:

    $('#calc').calculator('show');
    

    That “message passing” interface is the usual way of calling methods in the jQuery-UI world; the standard behavior for a jQuery plugin is to return a jQuery object for chaining so it is difficult for a plugin to return a custom object with normal JavaScript methods on it. To have chaining and the ability to call custom methods at the same time, you call the plugin with a method name and arguments:

    $(...).somePlugin('some_method', arg1, arg2, ...)
    

    Look at any of the Methods tabs in the jQuery-UI documentation for examples; the accordion has things like this:

    activate
    .accordion( "activate" , index )

    Activate a content part of the Accordion programmatically.

    There’s also a third show in play here and that’s this one:

    el.show();
    

    That show is just the usual jQuery show function.

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

Sidebar

Related Questions

I'm a complete noob to JQUERY, learning things slowly. But I have been downloaded
I'm learning jQuery and saw this chunk of code. myJqueryFile.js (function($, undefined) { function
I'm learning jQuery and this is my code so far: <script type=text/javascript> $(document).ready(function(){ $('#login').click(function(){
I'm learning JQuery and have found the factory function $() with its selectors quite
I've just started learning Jquery but the examples aren't helping me much... Now whats
I am learning JQuery, and I have ran into an odd issue. I made
i found http://visualjquery.com/ more useful when i was learning jQuery with each function explained
For learning jQuery UI dialog, I have the code defined below. I need to
Still learning jquery here and I've tried to setup a set of divs that
So I'm learning jQuery Mobile and I'm trying to run the following code below

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.