[jQuery] Re: Recommended way to overload jquery method?

2007-04-30 Thread Jörn Zaefferer
George schrieb: Hi Jörn, this technique seems like a good idea though I'm not sure I follow what you did in the metadata plugin. Would you be able provide an example here of how you would overload the trim function in the same way as the earlier posting? Sure thing. (function($) { v

[jQuery] Re: Recommended way to overload jquery method?

2007-04-30 Thread George
Hi Jörn, this technique seems like a good idea though I'm not sure I follow what you did in the metadata plugin. Would you be able provide an example here of how you would overload the trim function in the same way as the earlier posting? Many thanks, George On Apr 23, 7:14 pm, Jörn Zaefferer <

[jQuery] Re: Recommended way to overload jquery method?

2007-04-23 Thread Mike Alsup
For example, if jQuery were to define their trim() method as a prototype to the String object, then it would/could override a pre-defined version of the function. If the two functions did not behave *exactly* a like, now you have some issue that's very hard to debug and track down. I agree. O

[jQuery] Re: Recommended way to overload jquery method?

2007-04-23 Thread Dan G. Switzer, II
Matt, >Is there any reason why it's not done this way? Perhaps there are >things I'm not thinking of :) You can access the functions using $.trim(), etc. While I had no part in planning, I suspect the decision to place all this code w/in the jQuery object was to avoid having the jQuery code inte

[jQuery] Re: Recommended way to overload jquery method?

2007-04-23 Thread Matt Kruse
On Apr 23, 4:36 am, Remy Sharp <[EMAIL PROTECTED]> wrote: > Though if you're thinking of overloading functions like trim, wouldn't > it be better to extend the String object? Why doesn't jQuery extend existing objects (other than Object, of course) and then reference those methods instead of defi

[jQuery] Re: Recommended way to overload jquery method?

2007-04-23 Thread Jörn Zaefferer
howard chen schrieb: I want to overload some core jQuery method, e.g. trim() method any codes sample or recommendation to do this? Save a reference to the original method in a closure and call that when appropiate. An example for this can be found here: http://dev.jquery.com/browser/trunk/pl

[jQuery] Re: Recommended way to overload jquery method?

2007-04-23 Thread Remy Sharp
Example of (how I would) overload a function: jQuery.extend({ _trim: jQuery.trim, trim: function(s) { // do something to s first, then you might want to call original function this._trim.call(this, s); } }); Though if you're thinking of overloading functions like trim, wouldn't it