Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-28-2008, 12:18 PM
Junior Member
 
Join Date: Mar 2008
Posts: 3
Default Attaching Javascript on per page basis

Can anyone tell me please what is the best method in Zend of attaching JS on a per page basis?

Also, where in the application folder hierarchy would people say is teh best place to store JS files?

Thanks

Last edited by edward.lynn : 04-28-2008 at 12:21 PM. Reason: Missed a bit
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-29-2008, 05:33 PM
Member
 
Join Date: Jan 2008
Location: chicago
Posts: 98
Default

I store Javascript files in a folder called /javascript inside the public directory where your bootstrap file is. Your javascript files must be in this directory because they must be readable by the web browser.

If I only want to use Javascipt code for a specific page, I include it inline inside my template file (ex: index.phtml) at the top.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-29-2008, 05:53 PM
Junior Member
 
Join Date: Mar 2008
Posts: 3
Default

Thanks for the reply. What if you needed the JS to be in the head of the document?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-29-2008, 09:57 PM
Junior Member
 
Join Date: Oct 2007
Posts: 21
Default

Indeed, your javascript should be in a public directory, or people won't be able to access it.

There's a useful view helper for including scripts on demand called HeadScript.

You can add scripts in your view (or controller, of course) and then your layout or view script calls the helper to display them.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-30-2008, 08:17 AM
Junior Member
 
Join Date: Mar 2008
Posts: 3
Default

Thanks very much, that looks like what I need. As a beginner in Zend is there a good book I should start with? What would people recommend?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-30-2008, 11:13 AM
Junior Member
 
Join Date: Oct 2007
Posts: 21
Default

I'm not aware of any good books available yet - haven't really looked though.

Rob Allen (akrabat) is writing Zend Framework in Action (Manning: Zend Framework in Action). If its half as good as the tutorials on his blog (Akra’s DevNotes Zend Framework) I'm sure it'll be great.

I've learnt from practical experience. Don't be afraid to play with the components, and use the API to see what methods they have.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-30-2008, 02:16 PM
Elemental's Avatar
Senior Member
 
Join Date: Jul 2007
Posts: 119
Default

Here's a post for the books I've found.
__________________
Zend Framework Resources: Zend Webinars | Reference Manual | API Docs | Books | FreeNode: #zftalk
Getting Started Tutorials: Getting started with ZF | Getting started with Zend Auth
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:18 AM.