Where/how to add javascript to use jQuery?

Asked by jsherk

Just wondering where the best place to add my javascript is?

I am trying to figure out how to use jQuery in order to hide/show divs.

I have torn apart the phpds plugins page, but I cannot figure out how you get that horizontal bar which hides/shows the info for each plugin. I even copied and pasted the code from the .tpl file, but all I get is a thin horizontal line, and clicking it does not do anything. I do not see any includes in the .tpl file either, so I am not sure how you are doing it.

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
PHPDevShell Edit question
Assignee:
No assignee Edit question
Solved by:
jsherk
Solved:
Last query:
Last reply:
Revision history for this message
jsherk (jeff-forerunnertv) said :
#1

Ok, I found it!

You need to put this in your controller file:
$this->template->addJsFileToHead('plugins/path/to/filename.js');

Revision history for this message
TitanKing (titan-phpdevshell) said :
#2

Correct :)

Revision history for this message
Greg (gregfr) said :
#3

BTW, in case you are not fluent with JavaScript in general and jQuery in particular, I advise you take the time to learn it either from a tutorial or a book. They are using a paradigm (don't you love that empty word?;) called "unobstrusive JS" which can be uneasy to grasp at first look.

Revision history for this message
jsherk (jeff-forerunnertv) said :
#4

Yes, I spent last night going thru a jQuery tutorial.
Thanks

Revision history for this message
jsherk (jeff-forerunnertv) said :
#5

Been playing with jquery for a couple days now and I really like it... it has made javascript a whole lot easier!!

Revision history for this message
Greg (gregfr) said :
#6

Yes it's a big step forward. JS is a very dynamic field which evolves almost everyday (see for example http://www.infoq.com/articles/stratifiedjs).