Hi David

thanks a lot for the explanation an yes this code works fine

Event.observe(window, 'load', function() {
  computeTotalForTable('cities');
});

It's all more clear now,  thanks again

gio






On 27 May, 17:56, david <david.brill...@gmail.com> wrote:
> Hi again gio,
>
> some explanation on:
> Event.observe(window, 'load', function() {
>   Event.observe(window,'load',computeTotalForTable('cities'));
>
> })
>
> The first Event.observe register the handler function
> function() {
>   Event.observe(window,'load',computeTotalForTable('cities'));
>
> }
>
> so when the event is launched, you want to observe another event, but
> the computeTotalForTable is automatically executed
> because computeTotalForTable('cities') launch the function and return
> what retuen the function, instead of computeTotalForTable that return
> the function to be launched after the event apear.
>
> hope it'll be more clear :))
>
> --
> david
>
> On 27 mai, 17:31, gio <giov...@gmail.com> wrote:
>
> > Hi All,
>
> > I am new to prototype and I need a bit of an explanation on
> > Event.observe please - I have used it several times and it's been ok -
> > Now I have a function that builds a table row on the fly but it's
> > behaving a bit strange. (I can paste the code of the function if
> > needed - it's taken from the fabulous book "Practical Prototype and
> > script.aculo.us "  ).
>
> > I could not get it to work with this line of code:
>
> > Event.observe(window,'load',computeTotalForTable('cities'));
>
> > After searching on the prototype site I found out this solution but I
> > don't understand why this works:
>
> > Event.observe(window, 'load', function() {
> >   Event.observe(window,'load',computeTotalForTable('cities'));
>
> > });
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to