Another possible improvement would be to genericize the work I did on the
speed test.

Specifically, to avoid browser lockup, I did the following:
* I pass a list of DOM Elements to a function
* That function executes something on the first item, and when it's done,
passes the same list with the first item chopped off back to the same
function via setTimeout

Browsers lock up when they run JavaScript continuously. Using this method,
you can create small (few millisecond) breathing space between iterations,
which results in an avoidance of lockup or "non-responsive" errors. The only
drawback is that you need to create manual recursive methods to handle it.

I wonder if your method above could be expanded to support something like
$.runSequentially(list, function() { // some code to run sequentially });

-- Yehuda

On 12/27/06, Choan C. Gálvez <[EMAIL PROTECTED]> wrote:

On 12/27/06, Michael Geary <[EMAIL PROTECTED]> wrote:
> Not only not related to jQuery, but not related to closures either. :-)
>
> 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 );
>
> That would work in any browser.

I was intrigued by the syntax used by Moe, as I had never seen it.

It's documented at
<http://developer.mozilla.org/en/docs/DOM:window.setTimeout>, stating:

"Note that passing additional parameters to the function in the first
syntax does not work in Internet Explorer."

Anyway, as I see possible uses for it, I've coded a helper:

                function setTimeoutH(f, t) {
                        var params = [].slice.call(arguments, 2);
                        var f2 = function() {
                                f.apply(null, params);
                        }
                        return window.setTimeout(f2, t);
                }

Hope it helps someone.



> > i hope someone on this list can help me here, even tho
> > my question is not directly related to jquery (duck).
> >
> > i have trouble getting my closures to work in ie:
> >
> >
> > --snip
> >
> > //
> > // A) this doesn't work in ie (ff & opera grok it)
> > //
> > setTimeout(  function( a,b,c ) { doStuff( a,b,c ) }, 100,
> > "stuff", 1, 2  );
> >
> >
> > //
> > // 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 );
> >     });
> > }
> >
> > --snap
> >
> >
> > anyone know how to feed that to ie without
> > the nasty helper function?
--
Choan
<http://choangalvez.nom.es/>

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




--
Yehuda Katz
Web Developer | Wycats Designs
(ph)  718.877.1325
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to