Is it possible to write a jQuery plug-in that operates on each item in a jQuery object using this syntax:
(function ($){
$.fn.extend({
DoSomething: function(){
return this.each(function () {
//Do something to each item
});
//Run the general update
update();
}
});
})(jQuery);
But then I want to finish the function call with a general “update” operation.
How would I go about doing something like this? it will be quite slow if I do the update after each operation, rather than at the end, but I’ll be putting this code in a few places, so I was hoping not to separate this out into two calls: $(object).DoSomething().update();
Might not be what you are after, but:
Will execute your
this.each()functionality and then your update() function.