control-freak-ide/Control-Freak-Documentation/jQuery/docs/entries/callbacks.add.json
plastic-hub-dev-node-saturn 538369cff7 latest
2021-05-12 18:35:18 +02:00

1 line
1.3 KiB
JSON

{"name":"callbacks.add","type":"method","title":"callbacks.add()","deprecated":null,"removed":null,"desc":"Add a callback or a collection of callbacks to a callback list.","categories":["callbacks-object","version/1.7"],"entries":[{"return":"Callbacks","signatures":{"added":"1.7","argument":{"desc":"A function, or array of functions, that are to be added to the callback list.","type":[{"name":"Function"},{"name":"Array"}],"name":"callbacks"}},"examples":{"desc":"Use <code>callbacks.add()</code> to add new callbacks to a callback list:","code":"\n// A sample logging function to be added to a callbacks list\nvar foo = function( value ) {\n console.log( \"foo: \" + value );\n};\n\n// Another function to also be added to the list\nvar bar = function( value ) {\n console.log( \"bar: \" + value );\n};\n\nvar callbacks = $.Callbacks();\n\n// Add the function \"foo\" to the list\ncallbacks.add( foo );\n\n// Fire the items on the list\ncallbacks.fire( \"hello\" );\n// Outputs: \"foo: hello\"\n\n// Add the function \"bar\" to the list\ncallbacks.add( bar );\n\n// Fire the items on the list again\ncallbacks.fire( \"world\" );\n\n// Outputs:\n// \"foo: world\"\n// \"bar: world\"\n"},"longdesc":"\n <p>This method returns the Callbacks object onto which it is attached (<code>this</code>).</p>\n "}]}