Share » Forums » Setup & design » Call javascript functions in template...

Call javascript functions in template ? [to use ajax]

Call javascript functions in template ? [to use ajax]

Wednesday 04 July 2007 3:31:03 pm - 2 replies

Author Message

Bruce Morrison

Wednesday 04 July 2007 6:27:44 pm

Hi Eder

You have (at least) 2 options

Add the scripts to the design.ini of the siteacesss you want them used in

[JavaScriptSettings]
JavaScriptList[]=dajax/lib/prototype.js
JavaScriptList[]=dajax/src/scriptaculous.js

This method assumes they are under design/site_design/javascript directory (e.g. design/site_design/javascript/dajax/lib/prototype.js) and will add them to the head of each page.

The other method is to add them to the template e.g.

{run-once}
<script type="text/javascript" src={"javascript/dajax/lib/prototype.js"|ezdesign}></script>
<script type="text/javascript" src={"javascript/dajax/src/scriptaculous.js"|ezdesign}></script>
{/run-once}

<ul id="movies_list">
       <li id="movie_1">test 1</li>
       <li id="movie_2">test 2</li>
</ul>
       <script type="text/javascript">
           Sortable.create('movies_list');
       </script>

The run-once tags are there so if the template is used multiple times the javascripts are only included once. They may not be necessary.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Eder Silva

Friday 13 July 2007 8:22:51 am

Thanks so much !!

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu