Chains work by returning the original jQuery object as a result of calling this binder function. Hypothetically, to bind your anonymous functions, you must βreturnβ the original jQuery object.
However, your function must be called from the context of the jQuery object. For example, there is a function
$item.appendTo
However, for the jQuery object, there is no function available for:
$item.(function(){ })
Think of it this way. Let's say you have the following object:
var obj = { foo: function(){ console.log(1); } };
The declaration of 'foo' is available as a property / declaration on obj. But what exactly does the declaration that you refer to the anonymous function mean?
obj.(function(){ })
The only way to give your anonymous function the execution context of the jQuery object is to make a "call" on it
(function(){ }).call($item, args);
If you wanted to relate this, theoretically you could do this:
(function(){ return this; }).call($item, args).appendTo($other);
But I'm not sure what you get. Best to do this:
$item.appendTo($list); (function($obj){ })($item);
Or if you start with a selector:
var $item = $('#someID').appendTo($list); (function($obj){ })($item);
Although, at the moment, anonymous functions are not so useful, so I just:
var someFunc = function($obj){ }; $item.appendTo($list); someFunc($item);