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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:19:45+00:00 2026-05-26T17:19:45+00:00

I was looking through new stuff added to jQuery 1.7 and I saw they

  • 0

I was looking through new stuff added to jQuery 1.7 and I saw they now have jQuery.Callbacks() http://api.jquery.com/jQuery.Callbacks/.

The documentation shows you how to use jQuery.callbacks() but not any applicable examples of when I would want to use them.

It seems you can add/remove callbacks from a callbacks list and you can do jQuery.callbacks().fire(args), but this just fires off ALL of the callbacks in that list. Maybe I am missing something but this doesn’t seem very useful.

In my head when I first saw this new functionality I thought you would be able to use it with key/value pairs. Which would then provide a simple way to manage callback functions in a single place in your application. Something like

$.callbacks.add("foo", myFunction);

and then for example if I wanted to call that callback at the end of my function I could do something like

$.callbacks().fire("foo", args);

However it doesn’t look like you can fire off specific callbacks, you can only fire off all of them with the given arguments or none of them.

The closest thing I saw was being given the ability to give the .fire() function a context to set the “this” property

.fireWith(context, args)

but this doesn’t really help much either.

  1. Am I misunderstanding the documentation?

  2. If this is the desired functionality what are some applicable examples where this is useful.

  • 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-26T17:19:45+00:00Added an answer on May 26, 2026 at 5:19 pm

    To expand on @Rockets answer a bit and clear up some confusion:

    The reason that one might need to use jQuery’s $.Callbacks is multifaceted:

    1. The user has a lot of code in one function and wants to split it up
    2. They take that information and send it through the jQuery callback function which then allows them to have split their code into better manageable pieces with which to work with.
      So (for example) if you look at @Rocket’s code:

      var clickCallbacks = $.Callbacks();
      
      clickCallbacks.add(function() { //one one function piece
          //parse and do something on the scope of `this`
          var c = parseInt(this.text(), 10);
          this.text(c + 1);
      });
      clickCallbacks.add(function(id) { //add a second non-related function piece
          //do something with the arguments that were passed
          $('span', '#last').text(id);
      });
      
      $('.click').click(function() {
          var $ele = $(this).next('div').find('[id^="clickCount"]');
          clickCallbacks.fireWith($ele, [this.id]); //do two separate but related things.
      });
      
    3. What you can now have is multiple callback batches of function which you can now call whenever you deem it be necessary without the need to make so many changes throughout out your code.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking through the documentation for CFDataRef I can't see anything that will compress a
When looking through the documentation for SFML, I noticed the ability to rotate a
I have an application that is looking through some files for old data. In
I'm a somewhat new to python and was looking through the Django source code.
I have an account with Interactive Brokers. They have a decent trading API, but
I have a number of classes that do stuff, typically step through a recordset
i have been looking through the different questions as to how to remove spaces
I am kinda new to PHP, so I now have started using Pear where
I'm new to Ruby on Rails (I know Ruby just decently though) and looking
Looking through multiple iOS crash logs, I'm finding stack traces which are near identical

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.