Hi Mike,

On Wed, Dec 27, 2006 at 12:52:49AM -0800, Michael Geary wrote:
> Not only not related to jQuery, but not related to closures either. :-)

hrmbl, but it was such a nice keyword... ;)

> The problem is that setTimeout doesn't accept the additional arguments you
> are passing it.
> 
> Is there any reason you can't do this:
> 
> setTimeout( function() { doStuff( "stuff", 1, 2 ); }, 100 );

well, i need to pass some arguments to doStuff() that seem to
be out of scope when it fires.

to clarify, below is the relevant snippet of my real code
with your variant applied:

----snip

(function($) {
    $.fn.Tooltip = function(settings) {
        settings = $.extend($.extend({}, arguments.callee.defaults), settings 
|| {});

        $(this).filter('[EMAIL PROTECTED]')
            .each(function() {
                this.tSettings = settings;
            })
            .bind( settings.event, onmouseover );
        return this;
    };

//...

    function onmouseover( event ) {
        //...
             //
             // firebug throws "this.tSettings has no properties" on the next 
line
             // (when the timeout fires)
             //
             setTimeout(
                function() { 
                    on( $(this).attr('id'),
                        $(this).attr('ttbody'),
                        event.pageX + this.tSettings.xoffset,event.pageY + 
this.tSettings.yoffset
                      );
                 }, this.tSettings.ondelay );
        //...
    }

    function on( mysrcid, body, x, y ) {
        // do stuff...
    }

//...

})(jQuery);

----snap

as you may have guessed i'm tampering with the tooltip plugin
and am probably missing something obvious...


regards,
  moe


working example quoted for reference:

> > //
> > // B) this works in IE
> > //
> > var fref = iehelper( "stuff", 1, 2 );
> > setTimeout( fref, 100 );
> > 
> > function iehelper( a,b,c ) {
> >     return ( function() {
> >         doStuff( a,b,c );
> >     });
> > }


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to