web2py will produce a single HTML page to send to the browser, so look at 
the resulting code in that page, and it will be handled however the browser 
would normally handle such JS. If you are assigning an event handler to the 
window.onload event, I believe each new assignment will override any 
previous assignment 
(see 
http://www.htmlgoodies.com/beyond/javascript/article.php/3724571/Using-Multiple-JavaScript-Onload-Functions.htm).
 
Instead of window.onload, you might just use jQuery. Anything you put 
inside:

$(function () {
    [stuff to do upon DOM load goes here]
});

will be executed when the DOM has loaded (which I believe actually occurs 
before window.onload, which waits for assets like images to fully load -- 
see 
http://stackoverflow.com/questions/4395780/difference-bw-onload-and-document-readyfunction).

You can have multiple blocks like the one above on the page, and they will 
all get executed, so will work even if both the layout.html and extending 
view include such code.

Anthony

On Thursday, November 10, 2011 4:42:29 AM UTC-5, BrendanC wrote:
>
> This may be more of a js/browser question than a  web2py question, but I'd 
> like to clarify what happens in the following scenario.
>
> If I define an 'onload js call' in both the the base layout and a layout 
> that extends the base ( iow both templates make 'Onload' calls) which of 
> the following should happen:
>
>   - js/browser error
>   - base onload runs, but extended fails
>   - extended overrides base which never runs
>   - base runs, then extended 
>  - ?other?
>
> Is this covered anywhere in the docs - I'm not sure whether there are any 
> constraints re 'onload' behaviour when extending layouts.
>
> BrendanC
>
>
>

Reply via email to