Response title
This is preview!
(function($){
/**
* $.invoke(elements, func, context, extend)
*
* @param {array|object} list of elements to iterate
* @param {function} function with arguments(element, name)
* @param {context} applied this; default: current element
* @param {boolean} extend each element as jQuery object
*/
$.invoke = function(elements, func, context, extend){
return $.each(elements, function(name, elem){
func.apply(context || this, [extend ? $(elem) : elem, name]);
});
};
/**
* $('elements').invoke(function(elem, name){}, context)
*
* @param {function} function with arguments(element, name)
* @param {context} applied this; default: current element
*/
$.fn.invoke = function(func, context){
return $.invoke(this, func, context, true);
};
})(jQuery);
CustomElement = function(){
this.proxy = function(func, params){
...
};
jQuery('div.elements').invoke(function(div){
div.children("a:first").click(this.proxy('toggle', [element]));
}, this);
}
© 2013 jQuery Foundation
Sponsored by and others.