How to ensure a script appears only once on page?

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

How to ensure a script appears only once on page?

jgfoster
I'm looking at some of the YUI components, specifically the calendar  
widget, and am struggling with how to create a script. As I understand  
the YUI library, I am supposed to create a Javascript that references  
each of the calendar widgets on my page. The script has the general  
format of (begin, middle, end), where the middle has a variable amount  
of code but the begin and end are fixed. My problem is that I might  
have calendar widgets on various components, and the components should  
not each add the script, because then there would be multiple begins  
and ends.

Now, there might be a work-around for the YUI calendar situation, but  
I have a more general question: Is there some way to hook in to the  
beginning or end of a render process? I've come up with a crude  
approach where each component notifies the session at the beginning  
and end of a render and the session keeps track of the first in and  
then lets it know when it is the last out. Are there any other good  
ideas?

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

RE: How to ensure a script appears only once on page?

Sebastian Sastre-2
Hi James,

        I don't use YUI components (yet?) but I'm sure trying to control the
render flux to solve that problem is not a path which I like to take.

        If I understood well your scenario I've solved that by decoupling the
"configuring scripts time" from "render time" in a sub hierarchy of seaside
components.

        Achieved that, I'm able to "wire" arbitrary scripts at any
(pre-render)time with a guarantee of the hierarchy which make they to be
rendered properly (ocurrences and sequence).

        May you ponder to make something similar?

        cheers,

Sebastian Sastre

 

> -----Mensaje original-----
> De: [hidden email]
> [mailto:[hidden email]] En nombre
> de James Foster
> Enviado el: Miercoles, 19 de Marzo de 2008 02:00
> Para: [hidden email]
> Asunto: [Seaside] How to ensure a script appears only once on page?
>
> I'm looking at some of the YUI components, specifically the calendar  
> widget, and am struggling with how to create a script. As I
> understand  
> the YUI library, I am supposed to create a Javascript that
> references  
> each of the calendar widgets on my page. The script has the general  
> format of (begin, middle, end), where the middle has a
> variable amount  
> of code but the begin and end are fixed. My problem is that I might  
> have calendar widgets on various components, and the
> components should  
> not each add the script, because then there would be multiple begins  
> and ends.
>
> Now, there might be a work-around for the YUI calendar
> situation, but  
> I have a more general question: Is there some way to hook in to the  
> beginning or end of a render process? I've come up with a crude  
> approach where each component notifies the session at the beginning  
> and end of a render and the session keeps track of the first in and  
> then lets it know when it is the last out. Are there any other good  
> ideas?
>
> James
> _______________________________________________
> 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: How to ensure a script appears only once on page?

Ramon Leon-5
In reply to this post by jgfoster
> I'm looking at some of the YUI components, specifically the
> calendar widget, and am struggling with how to create a
> script. As I understand the YUI library, I am supposed to
> create a Javascript that references each of the calendar
> widgets on my page. The script has the general format of
> (begin, middle, end), where the middle has a variable amount
> of code but the begin and end are fixed. My problem is that I
> might have calendar widgets on various components, and the
> components should not each add the script, because then there
> would be multiple begins and ends.
>
> Now, there might be a work-around for the YUI calendar
> situation, but I have a more general question: Is there some
> way to hook in to the beginning or end of a render process?
> I've come up with a crude approach where each component
> notifies the session at the beginning and end of a render and
> the session keeps track of the first in and then lets it know
> when it is the last out. Are there any other good ideas?
>
> James

I use YUI calendar, but I'm really not following what you're trying to say,
can you be a little more explicit?  If you have multiple calendars on the
page, other than the generic includes of the calendar.js, why would the
calendars share any setup script?

Ramon Leon
http://onsmalltalk.com

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