Yes -- the second version works perfectly! Thanks!
On Apr 11, 12:55 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote: > The reason that doesn't work is that the $(theFunction) code has already > saved a reference to the actual function object for theFunction. When you > later replace the *name* theFunction with a different function object, it > has no effect on that existing reference. It still points to the original > function. > > BTW, a simpler way to say window['theFunction'] is window.theFunction - > means the same thing either way. > > Can you insert a script after jQuery is loaded but before the file in > question is loaded? If so, you could do something like this: > > if( $ != jQuery ) > alert( 'I made a bad assumption!' ); > $ = function( a ) { > if( a == theFunction ) > $ = jQuery; // ignore call and restore original $ > else > return jQuery.apply( this, arguments ); // allow other calls > }; > > Or perhaps a better way to code it is: > > (function() { > var old$ = $; > $ = function( a ) { > if( a == theFunction ) > $ = old$; // ignore call and restore original $ > else > return old$.apply( this, arguments ); // allow other calls > }; > })(); > > The second version avoids relying on the fact that $ is an alias for jQuery > - so it's a more general pattern that you could use in any similar > situation. > > Either way, by loading this code before the other script, youredefine$ so > it ignores the $(theFunction) call and then restores the original $ for > efficiency. > > -Mike > > > From: Noel > > > I want toredefinea function that is being bound to > > document.ready by someone else. Actually, I'd prefer just to > > unbind the function, but the initial binding is in a file > > that I don't want to change, and uses this syntax: > > > $(theFunction); > > > I understand fromhttp://dev.jquery.com/ticket/1311#comment:3 > > that this syntax is not supported for the 'unbind from document.ready' > > functionality that was added in 1.2.2. But I'm wondering if > > there is a way around this, for instance, toredefinethe > > function using something like: > > > window['theFunction'] = function () { // my definition... }; > > > But this doesn't seem to work -- the other definition of "theFunction" > > gets executed in any case. > > > Is there any way to achieve what I am trying to do without > > changing the other file?