[jQuery] Re: setInterval()

2009-08-24 Thread Michael Geary
> From: Nick Fitzsimons > Finally, by assigning a string to setInterval you are > basically performing an "eval", which is very inefficient. > Creating a function reference using a closure is the > preferred approach. A function reference is the best way to do it, but not so much because of ef

[jQuery] Re: setInterval()

2009-08-24 Thread Nick Fitzsimons
2009/8/23 solow : > function joinRoomFunction(roomId){ >        $("#tables").load("pages/pages.php", {r: roomId}, function() > { >                $("#myTable").tablesorter({widgets: ['zebra']}); >                alert('loaded'); >                 $('button#stopINTERVAAL').click(function() > {intva

[jQuery] Re: setInterval()

2009-08-24 Thread Michael Lawson
To: "jQuery (English)" Date: 08/24/2009 09:31 AM

[jQuery] Re: setInterval()

2009-08-24 Thread solow
I really need this

[jQuery] Re: setInterval()

2009-08-23 Thread solow
someone? please?..

[jQuery] Re: setInterval()

2009-08-23 Thread solow
Thanks for the reactions. but now, how do I see if the var has been set. *I'm using 'intvarM' as a var btw* Because when I click a hyperlink, or button, it says the vasn't been set. which is weird because the loop does update my fields. this is how i start an interval: function joinRoomFunction

[jQuery] Re: setInterval()

2009-08-21 Thread James
You probably shouldn't use 'int'. It may be a reserved word in Javascript. I suggest using a different variable name to be safe. On Aug 21, 11:01 am, solow wrote: > Hey, > > I have a question. > > I want to create a javascript loop, with setInterval(). > This loop has to be used in dynamicaly lo

[jQuery] Re: setInterval()

2009-08-21 Thread Leonard Martin
In this case you need to wrap the code inside the onclick in a function: onclick="function(){int=clearInterval(int);}" although obviously better would be to use $.click to bind the event: $('button#foo').click(function(){int=clearInterval(int);}); You will probably also want to check that the

[jQuery] Re: setInterval(obj.method,200) problem: scoping?

2009-01-02 Thread pete higgins
Because I'm an advocate for licensing and was told I probably should mention: the 'rescope' function is a stripped down version of Dojo's dojo.hitch function. Infinitely useful in the real world, but technically if used [in production] should retain attribution. It is available under new BSD and

[jQuery] Re: setInterval(obj.method,200) problem: scoping?

2009-01-02 Thread Alexandre Plennevaux
nice example, now i think i get it. Indeed actionscript (v2 at least) is based on ecmascript, much like javascript if i'm not mistaken. I came to web design/dev from actionscript one and gradually made my way to jquery. Anyway, actionscript keeps you away from the internal cooking by using a meta

[jQuery] Re: setInterval(obj.method,200) problem: scoping?

2009-01-02 Thread Alexandre Plennevaux
Thanks a lot Peter, that function is really neat ! On Sat, Jan 3, 2009 at 2:25 AM, pete higgins wrote: > > Here is your orig snippet rewritten to use the rescope function I pasted: > > var datascape = { > 'mouseX': 0, > 'myInterval': 0, > 'create': function(){ > $('#datascape').bind('mou

[jQuery] Re: setInterval(obj.method,200) problem: scoping?

2009-01-02 Thread Michael Geary
Thanks, Alexandre, it's kind of you to say that. About this code... > datascape.myInterval = setInterval(window.datascape.move,400); Let's break it down a little. It's exactly the same as doing: var callback = window.datascape.move; datascape.myInterval = setInterval( callback, 400 ); As

[jQuery] Re: setInterval(obj.method,200) problem: scoping?

2009-01-02 Thread pete higgins
Here is your orig snippet rewritten to use the rescope function I pasted: var datascape = { 'mouseX': 0, 'myInterval': 0, 'create': function(){ $('#datascape').bind('mousemove', rescope(this, function(e) { this.mouseX = e.pageX; })).bind("mouseover", rescope(t

[jQuery] Re: setInterval(obj.method,200) problem: scoping?

2009-01-02 Thread Alexandre Plennevaux
Michael, did you know that i 'm becoming a big fan of your explanations? if i follow your explanation correctly, this should have worked, isn't it ? datascape.myInterval = setInterval(window.datascape.move,400); Yet it didn't. I guess i 'm kind of assimilating the javascript window object to ac

[jQuery] Re: setInterval(obj.method,200) problem: scoping?

2009-01-02 Thread pete higgins
I've always found this bit of code useful: var rescope = function(scope, method){ if(!method){ method = scope; scope = null; } if(typeof method == "string"){ scope = scope || window; if(!scope[method]){ throw(['method not found']); }

[jQuery] Re: setInterval(obj.method,200) problem: scoping?

2009-01-02 Thread Michael Geary
Hi Alexandre, Don't go adopting a coding practice just because of a single mailing list message. :-) There's nothing wrong with quoting property names in an object literal, but the majority of experienced JavaScript programmers do not quote them except when necessary. As an example, browse throu

[jQuery] Re: setInterval(obj.method,200) problem: scoping?

2009-01-01 Thread Alexandre Plennevaux
hi Dave, thanks a lot for the feedback. The reason i'm not using the dom but rather more "conceptual" objects is because the application is quite complex, and its easier for my small brain to keep track of all variables as object properties. On Fri, Jan 2, 2009 at 2:02 AM, Dave Methvin wrote: >

[jQuery] Re: setInterval(obj.method,200) problem: scoping?

2009-01-01 Thread Dave Methvin
Whoops, I missed the original issue, which was that setInterval needs to be told its this object. So change this: this.interval = setInterval(function(){ $.log('datascape.move : mouseX = ' + this.mouseX); }, 1000); to this: var self = this; this

[jQuery] Re: setInterval(obj.method,200) problem: scoping?

2009-01-01 Thread Dave Methvin
jQuery works best when the DOM element is at the center of the logic. It seems like there are probably other parts to the code, but this would be another way to write what is there and have the data hooked to the datascape element. I've used plain properties on the DOM element but you might want t

[jQuery] Re: setInterval(obj.method,200) problem: scoping?

2009-01-01 Thread Alexandre Plennevaux
hi donb, according to a lengthy discussion we had on this mailinglist yesterday the quotes are good practice. see: http://groups.google.com/group/jquery-en/msg/821f4eb134c51d3d (is is just one message on a 31-long thread, if u have time ,read the whole thread it is interesting ) As for this issu

[jQuery] Re: setInterval(obj.method,200) problem: scoping?

2009-01-01 Thread donb
You should change 'move' to move (remove apostrophes). On Jan 1, 9:01 am, "Alexandre Plennevaux" wrote: > Hello mates, > > i have an object datascape which among other things, contains a > property storing the mouse position, and a function that uses that > property. Inside another method i > >

[jQuery] Re: setInterval method call with parameters not working

2008-11-23 Thread ricardobeat
Also from what I understand you're passing a string "{ param:'something' }", not an actual object to the ajax function, does that work? On Nov 23, 11:23 pm, "Karl Rudd" <[EMAIL PROTECTED]> wrote: > The setInterval() function can take a string (which is "evals") or a > "reference" to a function (w

[jQuery] Re: setInterval method call with parameters not working

2008-11-23 Thread Karl Rudd
The setInterval() function can take a string (which is "evals") or a "reference" to a function (which is the recommended way). To invoke a function via setInterval/setTimeout with arguments what is usually done to use an anonymous function/closure. So something like: slideshow_interval = setInt

[jQuery] Re: setInterval for $.get .php

2008-05-11 Thread Michael
Thanks, works! On May 11, 4:06 pm, "Mike Alsup" <[EMAIL PROTECTED]> wrote: > On Sun, May 11, 2008 at 7:51 AM, Michael <[EMAIL PROTECTED]> wrote: > > > Hello, i just recently started using jQuery and I have to say it works > > great. > > However I cannot figure out how to constantly (every 5 sec

[jQuery] Re: setInterval for $.get .php

2008-05-11 Thread Mike Alsup
On Sun, May 11, 2008 at 7:51 AM, Michael <[EMAIL PROTECTED]> wrote: > > Hello, i just recently started using jQuery and I have to say it works > great. > However I cannot figure out how to constantly (every 5 seconds for > example) refresh results by running the query script over and over. > > in

[jQuery] Re: setinterval vs. settimeout

2008-04-07 Thread coughlinsmyalias
Hey Ariel, I like this article, its laid out perfectly! On Apr 7, 1:03 pm, Ariel Flesler <[EMAIL PROTECTED]> wrote: > http://ejohn.org/blog/how-javascript-timers-work/ > > -- > Ariel Fleslerhttp://flesler.blogspot.com > > On 7 abr, 12:53, coughlinsmyalias <[EMAIL PROTECTED]> wrote: > > > Hey, I f

[jQuery] Re: setinterval vs. settimeout

2008-04-07 Thread ripple
My understanding is that setInterval is use for looping, cause once the time expires it executes again. It's a delay. Whereas setTimeout will not run again once the function is triggered. coughlinsmyalias <[EMAIL PROTECTED]> wrote: Hey, I found this article here: http://www.evolt.

[jQuery] Re: setinterval vs. settimeout

2008-04-07 Thread coughlinsmyalias
Thank you for this! This is exactly what I needed. Thanks Jake. Ryan On Apr 7, 12:51 pm, "Jake McGraw" <[EMAIL PROTECTED]> wrote: > The following will pop up an alert dialog EVERY 20 (2 milliseconds) > seconds: > > window.setInterval(function(){alert('Hello!');},2); > > The following wi

[jQuery] Re: setinterval vs. settimeout

2008-04-07 Thread Ariel Flesler
http://ejohn.org/blog/how-javascript-timers-work/ -- Ariel Flesler http://flesler.blogspot.com On 7 abr, 12:53, coughlinsmyalias <[EMAIL PROTECTED]> wrote: > Hey, I found this article > here:http://www.evolt.org/article/Using_setInterval_to_Make_a_JavaScript_L... > - to try to clear up my confu

[jQuery] Re: setinterval vs. settimeout

2008-04-07 Thread Jake McGraw
The following will pop up an alert dialog EVERY 20 (2 milliseconds) seconds: window.setInterval(function(){alert('Hello!');},2); The following will pop up an alert dialog ONCE, AFTER 20 (2 ms) seconds: window.setTimeout(function(){alert('Hello!');},2); To keep your site "update

[jQuery] Re: setInterval not working as i expect it to

2007-12-05 Thread Michael Geary
In both examples, you are calling setInterval with a text string containing code. This code is executed in the global context, i.e. outside any function. In your first example, alertMe() is a global function, so the call succeeds. In the second example, alertMe() is nested inside another functio

[jQuery] Re: setInterval, ajax call and LiveQuery : strange bug

2007-11-01 Thread Gonzo
Don't use setInterval on methods that use ajax. Instead use setTimeout as the last action in the callback for the ajax request. The ajax request takes time, so making the request at a specific interval may result in requests being processed much closer together than expected. What you really wa

[jQuery] Re: setInterval, ajax call and LiveQuery : strange bug

2007-10-31 Thread Flesler
Maybe http://jquery.com/plugins/project/Listen can help. On 31 oct, 12:21, "Samy RABIH" <[EMAIL PROTECTED]> wrote: > Dan, > It works better, but stills to start twice in 50% of cases > (if you have better idea to start events on ajax-generated content without > LiveQuery, I'm OK :) ) > > 2007/10/

[jQuery] Re: setInterval, ajax call and LiveQuery : strange bug

2007-10-31 Thread Samy RABIH
Dan, It works better, but stills to start twice in 50% of cases (if you have better idea to start events on ajax-generated content without LiveQuery, I'm OK :) ) 2007/10/31, Dan G. Switzer, II <[EMAIL PROTECTED]>: > > > Samy, > > >Hi all > >I'm french PHP developer (part of the Spongestats project

[jQuery] Re: setInterval, ajax call and LiveQuery : strange bug

2007-10-31 Thread Dan G. Switzer, II
Samy, >Hi all >I'm french PHP developer (part of the Spongestats project - >http://spongestats.sourceforge.net) and a newbie user of jQuery. > >I recently used jQuery to implement an ajax-powered refresh system for my >last visitors (as shown on http://fetardalyon.sytes.net/Spongestats/v3/). > >B

[jQuery] Re: setInterval not working

2007-10-18 Thread Josh Nathanson
bject, and your function will pick up the new value on the next iteration of setInterval. -- Josh - Original Message - From: "Alexandre Plennevaux" <[EMAIL PROTECTED]> To: Sent: Thursday, October 18, 2007 3:59 PM Subject: [jQuery] Re: setInterval not working thank

[jQuery] Re: setInterval not working

2007-10-18 Thread Alexandre Plennevaux
om Subject: [jQuery] Re: setInterval not working Alexandre, just to clarify: moveDatascape = function(el,mouseX,scrollSteps,stageWidth,frameWidth,maxX,minX) { return (function() { // rest of function follows }); // close the anonymous function } You need the p

[jQuery] Re: setInterval not working

2007-10-18 Thread Josh Nathanson
ust before the setInterval call. Keep hacking away at it, I think it will work! -- Josh - Original Message - From: "Alexandre Plennevaux" <[EMAIL PROTECTED]> To: Sent: Thursday, October 18, 2007 2:02 PM Subject: [jQuery] Re: setInterval not working hi Josh,

[jQuery] Re: setInterval not working

2007-10-18 Thread Alexandre Plennevaux
-en@googlegroups.com Subject: [jQuery] Re: setInterval not working I think you need to do something like this: myfunc = return moveDatascape('#dsViewport',mouseX,scrollSteps,stageWidth,frameWidth,maxX,minX); But, you don't want moveDatascape to actually execute at that point, so

[jQuery] Re: setInterval not working

2007-10-18 Thread Josh Nathanson
I think you need to do something like this: myfunc = return moveDatascape('#dsViewport',mouseX,scrollSteps,stageWidth,frameWidth,maxX,minX); But, you don't want moveDatascape to actually execute at that point, so you'll need to alter your moveDatascape function a bit: moveDatascape = func