<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Intro</title>
</head>
<body>
<h1>PICTURES</h1>
<h2>pics</h2>
<br>
<h3>x</h3>
<div id="contents">
</div>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.js"></script>
<script>
$("#contents").empty();
var pix = [
{figure: "figure", picfile:"bp/p01.jpg", alternative: "Parli", caption: "Parliament"},
{figure: "figurev", picfile:"bp/p04.jpg", alternative: "Donau", caption: "Boat trip"},
];
$.get("/tmpl/_picture.tmpl.htm", function(templates) {
$("#contents").append(templates);
$("#pictureTemplate").tmpl(pix).appendTo("#contents");
});
</script>
</body>
</html>
jQuery template problem
Page 1 of 11 Replies - 597 Views - Last Post: 31 January 2012 - 04:47 PM
Topic Sponsor:
#1
jQuery template problem
Posted 31 January 2012 - 04:34 PM
I'm experimenting with templates and this code stops with error "Object doesn't support this property or method". The error indication is on the line '$("#pictureTemplate").tmpl(pix).appendTo("#contents");' The page containing this code is called from another page where the jQuery library is defined. This code is taken from an example on the web with some modifications by me so I guess those are the ones causing the error but I can't figure out what it is.
Replies To: jQuery template problem
#2
Re: jQuery template problem
Posted 31 January 2012 - 04:47 PM
The jQuery Javascript has to be included on the same page that you are attempting to run this code. You can't include it on one page and pass off data to the other and expect it to work.
Secondly, where do you define the element with the ID #pictureTemplate? If it can't see this element, it is going to have a problem.

P.S. This is an issue with jQuery, not PHP. Moved.
Secondly, where do you define the element with the ID #pictureTemplate? If it can't see this element, it is going to have a problem.
P.S. This is an issue with jQuery, not PHP. Moved.
This post has been edited by Martyr2: 31 January 2012 - 05:09 PM
Page 1 of 1
|
|

New Topic/Question
Reply


MultiQuote




|