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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:37:41+00:00 2026-06-16T07:37:41+00:00

When reading Pub/Sub library by Ben Alman, I got confused at the very first

  • 0

When reading Pub/Sub library by Ben Alman, I got confused at the very first line that he passed an empty object into jQuery function. Also, he uses bind function object just to apply it in that nearly “empty” object (I used firebug to examine that object and it just return an jQuery object contain empty object inside). Could someone explain this logic for me?
Thank sooo much!
P/S: I understand the usage and the idea behind Pub/Sub pattern in non-framework context, just don’t understand its implementation in jQuery.

Here is the code of library I’ve read:

 (function($){
    var o = $({});
    $.subscribe = function() {
        o.bind.apply( o, arguments );
    };
    $.unsubscribe = function() {
        o.unbind.apply( o, arguments );
    };
    $.publish = function() {
        o.trigger.apply( o, arguments );
    };
 })(jQuery);
  • 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-16T07:37:42+00:00Added an answer on June 16, 2026 at 7:37 am

    WHen you create a jQuery object of an element… final object includes all the jQuery methods

    Over simplified example:

    { element: 'div'
        jQuery:{
          hide:function(){},
          animate:function(){}
           on:function(){}
        }
    
    }
    

    The empty object in the demo code is used to be able to do the same thing. Once it is wrapped in $() it can have jQuery event handlers bound to it as the object includes many of the jQuery methods( not all) as properties

    You could write:

    o.on('myCustomeEvent',doSomething);
    

    And in another part of code

    o.trigger('myCustomeEvent');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading http://dsecrg.com/files/pub/pdf/XSS_in_images_evasion_bypass_(eng).pdf , it is clear that allowing image uploads from users opens
After reading through the pub/sub project sample in MassTransit, it left me scratching my
Reading manual about Sling http://sling.apache.org/site/46-line-blog.html added folder blog and blog.html to destination: \launchpad\content\src\main\resources\content\ but
Reading through this excellent article about safe construction techniques by Brain Goetz, I got
Reading some questions here on SO about conversion operators and constructors got me thinking
I am making an application of e book reading, in that i want to
Reading through the other questions that are similar to mine, I see that most
Reading up on design patterns, and have found that there are 23(?) some-odd patterns
Reading the FTP RFC (RFC959), I notice some modes that I've never seen used,
Reading around Nokia forums, it seems that accessing the Cell ID and related information

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.