Where/how to add javascript to use jQuery?

Asked by jsherk on 2010-12-16

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:
2010-12-16
Last query:
2010-12-16
Last reply:
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');

TitanKing (titan-phpdevshell) said : #2

Correct :)

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.

jsherk (jeff-forerunnertv) said : #4

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

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!!

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).