Juha Suni schrieb: > Maybe I'm missing something but I don't see the difficulty here. > There's definately no need to do excessive core hacking or chaining of > mouseover and mouseout... > > Why not just: > > function myFunction() > { > $(this).append(' hover!'); > } > > And then: > > $('#hoverelem').hover(myFunction,myFunction); > > or... ? > > Same goes with other jQuery event functions that takes functions as > parameters. They don't necessarily need to be dynamic and defined right > then and there, you can just provide a pointer to the function instead. > If you want to pass in additional parameters, most likely stuff that you > can't get from the targeted element (this) or the event object, then you > might need to wrap some stuff in a dynamic function.
Another pattern for this would be a function that returns a function (or maybe you meant that with "dynamic function"): function myFunction(s) { return function() { $(this).append(s); }; } $('#hoverelem').hover(myFunction('foo'), myFunction('bar')); -- Klaus _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/