Page 1 of 1
tpl files + javascript
Posted: Mon Aug 08, 2005 9:32 pm
by taldos
quick newbie question.
Is there a trick to making javascript work when using tpl files. I have created an html file and written some code for form validation. However, once I switch the extention to tpl javascript stops working. Is there a way for me to still use this.
Posted: Tue Aug 09, 2005 7:47 am
by feyd
a browser may not now what to do with such a file if directly loaded. In fact, it shouldn't. A tpl file is meant to be processed by the server.
Re: tpl files + javascript
Posted: Tue Aug 09, 2005 8:52 am
by Roja
taldos wrote:quick newbie question.
Is there a trick to making javascript work when using tpl files. I have created an html file and written some code for form validation. However, once I switch the extention to tpl javascript stops working. Is there a way for me to still use this.
Your phrasing is unclear, but I suspect I know what you mean.
In Smarty, when you put javascript into a template file, you have to use literal tags.
http://smarty.incutio.com/?page=SmartyF ... template-3
However, a much better solution is to have the javascript in a standalone file, and reference the javascript file in your html. That way, the javascript file can be cached - saving piles of download time and bandwidth!
Code: Select all
<script type="text/javascript" defer="defer" src="backends/javascript/clear_default.js"></script>