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
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
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
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;
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:
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
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)
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();
})
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(
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
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
11 matches
Mail list logo