Actually, one part of this would be ZF specific. You would need to be
able to write a selector that only listens to events on one particular
module/controller/action. I typically do this with a Route Context
plugin that includes the module, controller, and action names as body
classes (and sometimes other application specific data depending on my
needs). This isn't perfect: you need to watch out for naming conflicts
between modules, controllers, and actions (or use prefixes in your
class names). However, once you have body classes that are unique for
various modules, controllers, and actions you can use those as part of
your selectors in jQuery (or whatever JavaScript library you're
using). Here's some example code:

http://gist.github.com/244249

On Fri, Nov 27, 2009 at 4:31 PM, Bradley Holt
<[email protected]> wrote:
> I'd consider using unobtrusive JavaScript so that you can add event
> listeners without having to add them directly to your body element.
> You can do this with jQuery or pretty much any other JavaScript
> library. Email me off-list if you want more info on how this would be
> done (since it's not ZF related).
>
> On Fri, Nov 27, 2009 at 3:45 PM, tonystamp <[email protected]> wrote:
>>
>> Hello
>>
>> I am using a layout for about 30 pages, but one page which has a google map
>> embedded in it requires that i add two events to the body tag of the
>> document. Obviously i don't want to add it for every page that doesn't need
>> it, so i'm not going to add it to the layout (it would also cause js errors,
>> as the js code is included in the page with the map in it).
>>
>> Is there a way to simply add the extra line of code to the body in the
>> controller, or will i need to use another layout to define the body events
>> just for that page? It would seem a waste, as everything else is identical
>> :?
>> --
>> View this message in context: 
>> http://n4.nabble.com/Adding-onload-event-to-body-on-one-page-only-tp797274p797274.html
>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>
>
>
>
> --
> Bradley Holt
> [email protected]
>



-- 
Bradley Holt
[email protected]

Reply via email to