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.
tpl files + javascript
Moderator: General Moderators
Re: tpl files + javascript
Your phrasing is unclear, but I suspect I know what you mean.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.
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>