我正在使用 JSRender 来呈现模板。
我在演示中使用第一个示例-
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
<link href="../resources/demos.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a href="../demos.html">JsRender Demos</a><br />
<h3>Render template against local data</h3>
<script id="movieTemplate" type="text/x-jsrender">
<!-- This thing i want to change dynamically -->
<div>
{{:#index+1}}:<b>{{:Close}}</b> ({{:Open}})
</div>
</script>
<div id="movieList"></div>
<script type="text/javascript">
var movies = [
{ name: "The Red Violin", releaseYear: "1998" },
{ name: "Eyes Wide Shut", releaseYear: "1999" },
{ name: "The Inheritance", releaseYear: "1976" }
];
// Render the template with the movies data and insert
// the rendered HTML under the "movieList" element
$( "#movieList" ).html(
$( "#movieTemplate" ).render( movies )
);
</script>
</body>
</html>
我需要的是在运行时更改模板。也就是里面的<div>
内容<script id=movieTemplate">
谁能帮我解决这个问题。
感谢您分享您的智慧。