Sachin has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
Problem 1. When i run my Catalyst Application i got the following Bug. Couldn't render template "file error - site.tt: not found" if I run it from the built in server it works fine but when it's run through Apache(like it usually is) it's not working now?
Problem 2 . How to use Jquery With Catalyst Application? I put the JS file in separate folder root/static/js folder. But when i run the my application then it's showing message in error console "$ is not define". (I got the meaning of it, but unable to solve it out.) Code is following JS file
function makeactive(tab) { document.getElementById("tab1").className = ""; document.getElementById("tab2").className = ""; document.getElementById("tab3").className = ""; document.getElementById("tab"+tab).className = "active" +; } //For Display and hide Div with Jquery $(document).ready(function(){ $('#click').hide(); $('#owner_close').hide(); $('a#click').click(function(){ $('#CreateSite').show('slow'); $('#click').hide(); $('#close').show(); }); $('a#close').click(function(){ $('#CreateSite').hide('slow'); $('#click').show(); $('#close').hide(); }); $('#OwnerDetail').hide(); $('a#owner_click').click(function(){ $('#OwnerDetail').show('slow'); $('#owner_click').hide(); + $('#owner_close').show(); }); $('a#owner_close').click(function(){ $('#OwnerDetail').hide('fast'); $('#owner_close').hide('slow'); $('#owner_click').show('fast'); }); });
And My site.tt file is following
<html> <head> <title>[% template.title or "My Catalyst App!" %]</title> <link rel="stylesheet" href="[% c.uri_for('/static/css/tool.css') %]" +type="text/css" media="screen, print" /> <script type="text/javascript" src="[% c.uri_for('/static/js/Tool.js') + %]"> </script> <script type="text/javascript" src="[% c.uri_for('/static/js/jquery.js +') %]" ></script> </head> <body> <div id="header"> <img src="[% c.uri_for('/static/images/logo.gif') %]" title="GISTFIND +Logo"/><p align="right">ADMINISTRATION PORTAL</p> </div> <div id="navigation"> <ul> <li onclick="makeactive(1)"><a href="#" name="na +vHome" class="selected" id="tab1" title="Home">Home</a></li> <li onclick="makeactive(2)"><a href="#" class="" + name="navAccountMgmt" id="tab2" title="Account Management">Account m +anagement</a></li> <li onclick="makeactive(3)"><a href="#" class="" + name="navSiteAdmin" id="tab3" title="Site">Site Admin</a></li> <br class="clear" /> </div> <div class="page-wrapper"> <div class="page"> <h3 style="background:#999999;font-weig +ht:bold;">Create Site</h3> <form id="signupForm"> + <div id="CreateSite"> <table id="tblcreatesit +e" cellspacing="0" cellpadding="0" border="1" style="empty-cells: hid +e;"> <tr> <td>SITE CODE</ +td> <td><input type +="textbox" name="txtscode" id="scode" value="></td><td><a href="#" cl +ass="delete" style="color:#FF0000;">Delete</a></td> </tr> <tr> <td>Name</td> <td><input type +="textbox" name="txtsname" id="sname" value=""></td> </tr> <tr><td colspan="2"> <div align="rig +ht"><input type="submit" name="sbtnCreateSite" value="Submit"/> <input type="re +set" name="rbtnReset" value="Reset"/></div></td> </tr> </table> </div> </form> <div align="right"><a h +ref="#" id="owner_click">Owner Detail</a><a href="#" id="owner_close" +>Close</a></div> <form name="frmOwnerinf +o" id="Ownerinfo"> <div id="OwnerDetail"> <table cellspacing="0" +cellpadding="0" border="1"> <tr style="background:# +666666;font-weight:bold;"> <td colspan="2" + style="background-color:#666666;">Owner Detail</td> </tr> <tr> <td>Owner</td> <td><input type +="textbox" name="txtSiteOwner" id="site_owner" value="" ></td> </tr> <tr> <td>Contact Num +ber</td> <td><input type +="textbox" name="txtSiteOwnercontnumber" id="site_ownercontnumber" va +lue=""></td> </tr></table> </div> </form> + </p> </div> </body> </html>
  • Comment on Getting Error: Couldn't render template file error - site.tt: not found". When Run The Catalyst Application.
  • Select or Download Code

Replies are listed 'Best First'.
Re: Getting Error: Couldn't render template file error - site.tt: not found". When Run The Catalyst Application.
by marto (Cardinal) on May 21, 2010 at 10:28 UTC

    "Problem 2 . How to use Jquery With Catalyst Application? I put the JS file in separate folder root/static/js folder. But when i run the my application then it's showing message in error console "$ is not define". (I got the meaning of it, but unable to solve it out.) Code is following JS file "

    The "$ is not defined" error is most likely a result of the jquery.js file not being referenced in the correct location. Does Firebug show any errors in the net tab? Also that's an odd mix of regular JavaScript (in your makeactive function) and jQuery code :)

    Update: Also, you may want to include the jquery library prior to the Tools.js script.

      I put my jquery.js file in the same folder( static/js/). Please let me know how is odd mix of regular javascript and Jquery code? If there is any best way to use it then please tell me..

        "I put my jquery.js file in the same folder( static/js/)."

        And what? Everything now works?

        "Please let me know how is odd mix of regular javascript and Jquery code?"

        You load the jQuery framework, in one section you address things in the jQuery form $('#elementID').attribute(value); yet elsewhere in your code you use the general form  document.getElementById("elementID").attribute = value;. If it does what you want then it's not a problem. It just seems like an odd mix of the jQuery framework and plain JavaScript. I tend to like things to be consistent.

        I have the same problems now. Did you have a solution? Thank you, tolq.