Q on Periodical

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Q on Periodical

squeakman
Hello,

Is there any way to setup a periodical but not have it running initially?

I guessed that using "evalScripts: false" would result in the script not
being executed but that did not work.

Here is the code that I am using:

html script: ((html scriptaculous periodical)
        id: self domId;
        frequency: 5;
        on: self triggerMethod of: self parent;
        evalScripts: false;
        assignTo: 'FLPer').


What I want to do is have the script assigned to the javascript variable
"FLPer" but not have it executed until a later time.

Thanks for any help you can provide,

Frank

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Q on Periodical

sebastianconcept@gmail.co
put it in a variable and stop it just after creating it.
 that way, it never executes until you tell it to start again




On Oct 9, 2011, at 12:03 PM, squeakman wrote:

Hello,

Is there any way to setup a periodical but not have it running initially?

I guessed that using "evalScripts: false" would result in the script not being executed but that did not work.

Here is the code that I am using:

html script: ((html scriptaculous periodical)
id: self domId;
frequency: 5;
on: self triggerMethod of: self parent;
evalScripts: false;
assignTo: 'FLPer').


What I want to do is have the script assigned to the javascript variable "FLPer" but not have it executed until a later time.

Thanks for any help you can provide,

Frank

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Q on Periodical

squeakman
That is exactly what I tried (in addition to the "evalScripts: false")
but it seems that the Periodical is always triggered once initially.
What I observed is that it is triggered once on creation.

Below is the code I tried to initially turn it off - but seemingly to no
avail.

 >> html script: ((html scriptaculous periodical)
 >> id: self domId;
 >> frequency: 5;
 >> on: self triggerMethod of: self parent;
 >> evalScripts: false;
 >> assignTo: 'FLPer').

html script: 'FLPer.stop();'. "turn off initially"


And, as an aside, shouldn't the evalScripts: false result in it not
running or is my understanding incorrect?

Thanks for your help,
Frank

On 09/10/2011 11:28 AM, Sebastian Sastre wrote:

> put it in a variable and stop it just after creating it.
> that way, it never executes until you tell it to start again
>
>
>
>
> On Oct 9, 2011, at 12:03 PM, squeakman wrote:
>
>> Hello,
>>
>> Is there any way to setup a periodical but not have it running initially?
>>
>> I guessed that using "evalScripts: false" would result in the script
>> not being executed but that did not work.
>>
>> Here is the code that I am using:
>>
>> html script: ((html scriptaculous periodical)
>> id: self domId;
>> frequency: 5;
>> on: self triggerMethod of: self parent;
>> evalScripts: false;
>> assignTo: 'FLPer').
>>
>>
>> What I want to do is have the script assigned to the javascript
>> variable "FLPer" but not have it executed until a later time.
>>
>> Thanks for any help you can provide,
>>
>> Frank
>>
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> <mailto:[hidden email]>
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> sebastian <http://about.me/sebastianconcept>
>
> o/
>
>
>
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Q on Periodical

Lukas Renggli
> And, as an aside, shouldn't the evalScripts: false result in it not running
> or is my understanding incorrect?

Please check the method comment of the method:

  PTUpdater>>evalScripts: aBoolean
      "This determines whether <script> elements in the response text
are evaluated or not. The default implementation of Prototypes does
not evaluate script, however this implementation changes this odd
behavior."

      self options at: 'evalScripts' put: aBoolean

An in-depth description you also find in the PrototypeJS documentation:

  http://api.prototypejs.org/ajax/Ajax/Updater/

Navigating to the subclass should answer your original question:

  http://api.prototypejs.org/ajax/Ajax/PeriodicalUpdater/

The periodical updater does always trigger a request in the first
place. You can also see that in the source code:

  https://github.com/sstephenson/prototype/blob/1fb9728/src/ajax/periodical_updater.js#L220

So this means you should only create a periodical updater when you
also want to start it.

Lukas

--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Q on Periodical

Bob Arning
In reply to this post by squeakman
I'm not sure why you want to create the periodical before you need it to run, but this seems to do what you wanted:

renderContentOn: html

    html div
        script: ((html scriptaculous periodical)
            frequency: 1;
            on: #renderNextImageOn: of: self;
            assignTo: 'FLPer'
            ), (
                html prototype script add: (JSStream new
                    nextPutAll: 'FLPer.stop();';
                    yourself)
                );

        with: [html text: 'this is a test'].
    html div       
        onClick: ('FLPer.start();');
        with: 'start me'.
    html div       
        onClick: ('FLPer.stop();');
        with: 'stop me'.
       
Cheers,
Bob

On 10/9/11 12:22 PM, squeakman wrote:
That is exactly what I tried (in addition to the "evalScripts: false") but it seems that the Periodical is always triggered once initially. What I observed is that it is triggered once on creation.

Below is the code I tried to initially turn it off - but seemingly to no avail.

>> html script: ((html scriptaculous periodical)
>> id: self domId;
>> frequency: 5;
>> on: self triggerMethod of: self parent;
>> evalScripts: false;
>> assignTo: 'FLPer').

html script: 'FLPer.stop();'.    "turn off initially"


And, as an aside, shouldn't the evalScripts: false result in it not running or is my understanding incorrect?

Thanks for your help,
Frank

On 09/10/2011 11:28 AM, Sebastian Sastre wrote:
put it in a variable and stop it just after creating it.
that way, it never executes until you tell it to start again




On Oct 9, 2011, at 12:03 PM, squeakman wrote:

Hello,

Is there any way to setup a periodical but not have it running initially?

I guessed that using "evalScripts: false" would result in the script
not being executed but that did not work.

Here is the code that I am using:

html script: ((html scriptaculous periodical)
id: self domId;
frequency: 5;
on: self triggerMethod of: self parent;
evalScripts: false;
assignTo: 'FLPer').


What I want to do is have the script assigned to the javascript
variable "FLPer" but not have it executed until a later time.

Thanks for any help you can provide,

Frank

_______________________________________________
seaside mailing list
[hidden email]
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

sebastian <http://about.me/sebastianconcept>

o/





_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Q on Periodical

squeakman
On 09/10/2011 2:37 PM, Bob Arning wrote:
> I'm not sure why you want to create the periodical before you need it to
> run
>

Hi Bob,

I have a "Play" button that when hit will display a series of images one
per x seconds.  I want to use the periodical to trigger a new image
every x seconds.

I want to do this using Ajax - when the "Play" button is hit I have an
Ajax callback that on the first invocation, sets up the Periodical.  My
problem is that I cannot figure out how to setup the periodical in an
Ajax callback.

Because I cannot figure out how to start the Periodical in an Ajax
callback, my "solution" was to setup the Periodical in my
renderContentOn: and immediately stop it.  Later when the "Play" button
is hit, I start the Periodical.

I hope that explains what I am up to.

I do appreciate your help, thanks.

Cheers,
Frank

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Q on Periodical

squeakman
In reply to this post by Lukas Renggli
On 09/10/2011 2:19 PM, Lukas Renggli wrote:

> Please check the method comment of the method:
>
>    PTUpdater>>evalScripts: aBoolean
>        "This determines whether<script>  elements in the response text
> are evaluated or not. The default implementation of Prototypes does
> not evaluate script, however this implementation changes this odd
> behavior."
>

I did read this before posting and I was not sure how to interpret the
comments.  I interpreted

    "however this implementation changes this odd behavior"

as stating that the current implementation overcomes the default "odd
behaviour".

Your explanation helped me a lot, thanks.

I have to admit that I am still a bit confused about when one would use
evalScripts: false - it seems as if it does nothing. Same argument for
evalJs: false.

Obviously I am still struggling to understanding.

Thanks,
Frank


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Q on Periodical

Bob Arning
In reply to this post by squeakman
Well, that seems easier...

renderContentOn: html

    html div
        onClick: ((html scriptaculous periodical)
            frequency: 1;
            on: #renderNextImageOn: of: self;
            assignTo: 'FLPer'
            );

        with: [html text: 'click to start'].

    html div       
        onClick: ('FLPer.stop();');
        with: 'click to stop'.
       
Cheers,
Bob

On 10/9/11 3:57 PM, squeakman wrote:
On 09/10/2011 2:37 PM, Bob Arning wrote:
I'm not sure why you want to create the periodical before you need it to
run


Hi Bob,

I have a "Play" button that when hit will display a series of images one per x seconds.  I want to use the periodical to trigger a new image every x seconds.

I want to do this using Ajax - when the "Play" button is hit I have an Ajax callback that on the first invocation, sets up the Periodical.  My problem is that I cannot figure out how to setup the periodical in an Ajax callback.

Because I cannot figure out how to start the Periodical in an Ajax callback, my "solution" was to setup the Periodical in my renderContentOn: and immediately stop it.  Later when the "Play" button is hit, I start the Periodical.

I hope that explains what I am up to.

I do appreciate your help, thanks.

Cheers,
Frank

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Q on Periodical

Lukas Renggli
In reply to this post by squeakman
PrototypeJS by default does not evaluate JavaScript code (<script>
tags) that is part of an AJAX response. Unfortunately most of the time
you want such JavaScript code to execute, otherwise you wouldn't have
told Seaside to generate it. Thus Seaside changes the default
(PTUpdater>>#initialize) and makes that JavaScript code is executed by
default.

Lukas

On 9 October 2011 22:09, squeakman <[hidden email]> wrote:

> On 09/10/2011 2:19 PM, Lukas Renggli wrote:
>
>> Please check the method comment of the method:
>>
>>   PTUpdater>>evalScripts: aBoolean
>>       "This determines whether<script>  elements in the response text
>> are evaluated or not. The default implementation of Prototypes does
>> not evaluate script, however this implementation changes this odd
>> behavior."
>>
>
> I did read this before posting and I was not sure how to interpret the
> comments.  I interpreted
>
>   "however this implementation changes this odd behavior"
>
> as stating that the current implementation overcomes the default "odd
> behaviour".
>
> Your explanation helped me a lot, thanks.
>
> I have to admit that I am still a bit confused about when one would use
> evalScripts: false - it seems as if it does nothing. Same argument for
> evalJs: false.
>
> Obviously I am still struggling to understanding.
>
> Thanks,
> Frank
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>



--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside