I am using jquery templates on several projects. Thing is, in order to get a consistent feel, I was planning to put all the common templates on a CDN server, and then load them from different services with (in head):
<script id="errorPage" src="http://www.mycdn.com/error-page.html" type="text/x-jquery-tmpl"></script>
Then (in page ready handler), I use the following code to render my template:
$("#errorPage").tmpl("errorPage", {'message': 'Permission denied'}).prependTo("body");
Thing is … it doesn’t work !? nothing is rendered … I don’t know if it is even possible. I am very new to jquery-template, so I might also be missing something obvious !!!
Any idea ?
How does your template look like? Is browser processing it as html or as javascript? Try putting it in .js file or loading your templates as a string variables in javascript file. Instead of
load some .js file which has something like this:
You can have one or more js files with templates, but should have javascript as a source, not html.
UPDATE after I tried your scenario:
When loaded the way how you tried, contents of error-page.html are not parsed as jquery template and you get empty errorPage variable.