Re: [jQuery] jQuery Kinda Plugin: every

2006-10-20 Thread Blair Mitchelmore
Good suggestions John as always. .in() can't be done because 'in' is a JS keyword and I wouldn't want to have to call it like $()['in']() all the time. So I figured two JS keywords smashed together would work and chose .doin() as the function name; if you have any better ideas (maybe

Re: [jQuery] jQuery Kinda Plugin: every

2006-10-20 Thread Blair Mitchelmore
Once again, I have an 11th hour code change. I had forgotten about Jörn's suggestion of allowing additional passed arguments. I'm not entirely sure what kind of implementation or usage was expected but I added my own version. Any argument provided to the .doin()/.every() function beyond the

Re: [jQuery] jQuery Kinda Plugin: every

2006-10-20 Thread Blair Mitchelmore
Michael Geary wrote: You can simplify that code quite a bit. every() and doin() are nearly identical, so they can both call a common implementation. Ditto for the two inner loops in stop(). Great suggestions Mike. I noticed that they were very similar but I was too lazy to combine them but

[jQuery] jQuery Kinda Plugin: every

2006-10-19 Thread Blair Mitchelmore
I don't know if this exists already but I needed this and assumed it didn't and wrote it myself. Essentially it lets you do something to an element every given time interval. jQuery.fn.every = function(interval,fn) { return this.each(function() { var self = this;

Re: [jQuery] jQuery Kinda Plugin: every

2006-10-19 Thread Blair Mitchelmore
And I just realized I should make it possible to stop the repeating function later on. Code: jQuery.fn.every = function(interval,fn) { return this.each(function() { var self = this; this.$every = window.setInterval(function() { fn.call(self) },interval); }); }; Example:

Re: [jQuery] jQuery Kinda Plugin: every

2006-10-19 Thread Brian Miller
While it's not very jQuery-like, timers lend themselves to registration. I would attach an object to window or a more permanently/easily available object. This way, you don't have to leave closures around just to keep references to the timers, just so you can stop them later. Also, if you're

Re: [jQuery] jQuery Kinda Plugin: every

2006-10-19 Thread Jörn Zaefferer
Blair Mitchelmore schrieb: And I just realized I should make it possible to stop the repeating function later on. Code: jQuery.fn.every = function(interval,fn) { return this.each(function() { var self = this; this.$every = window.setInterval(function() { fn.call(self)

Re: [jQuery] jQuery Kinda Plugin: every

2006-10-19 Thread John Resig
What if you had a trifecta of functions: .every() .in() .stop() and allow for function calls like this: .every( 100, text, function(){ if ( !$(this).val() ) $(this).stop(text); }); or if you don't care about a name: .in( slow, function(){ $(this).hide(); })

Re: [jQuery] jQuery Kinda Plugin: every

2006-10-19 Thread Yehuda Katz
Those 3 functions would be extremely nice, and provide some much-needed built-in observer functionality (a la prototype's observer).-- YehudaOn 10/19/06, John Resig [EMAIL PROTECTED] wrote: What if you had a trifecta of functions:.every().in().stop()and allow for function calls like this:.every(

Re: [jQuery] jQuery Kinda Plugin: every

2006-10-19 Thread Dave Methvin
To: jQuery Discussion. Subject: Re: [jQuery] jQuery Kinda Plugin: every What if you had a trifecta of functions: .every() .in() .stop() and allow for function calls like this: .every( 100, text, function(){ if ( !$(this).val() ) $(this).stop(text); }); or if you don't care about a name

Re: [jQuery] jQuery Kinda Plugin: every

2006-10-19 Thread Blair McKenzie
I like that :DA way around the one element-one tick would be to have an optional second argument on interval and timeout to label the tick. e.g. interval(1000, abc)...bind(tick-abc, function() {}) BlairOn 10/20/06, Dave Methvin [EMAIL PROTECTED] wrote: Since the event handling has recently been