Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen would I use JQuery.Callbacks?
    primarykey
    data
    text
    <p>I was looking through new stuff added to jQuery 1.7 and I saw they now have jQuery.Callbacks() <a href="http://api.jquery.com/jQuery.Callbacks/" rel="noreferrer">http://api.jquery.com/jQuery.Callbacks/</a>. </p> <p>The documentation shows you how to use jQuery.callbacks() but not any applicable examples of when I would want to use them.</p> <p>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.</p> <p>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</p> <pre><code>$.callbacks.add("foo", myFunction); </code></pre> <p>and then for example if I wanted to call that callback at the end of my function I could do something like</p> <pre><code>$.callbacks().fire("foo", args); </code></pre> <p>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.</p> <p>The closest thing I saw was being given the ability to give the .fire() function a context to set the "this" property </p> <pre><code>.fireWith(context, args) </code></pre> <p>but this doesn't really help much either.</p> <ol> <li><p><strong>Am I misunderstanding the documentation?</strong></p></li> <li><p><strong>If this is the desired functionality what are some applicable examples where this is useful.</strong></p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload