$(document).ready(function(){
$('form').live('submit', function(){
$('#template').tmpl([{ "id" : "555" }, { "in" : "checked" } ]).prependTo('#content');
});
});
與與HTML
<!DOCTYPE html>
<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
<script src="http://jqueryui.com/ui/jquery.ui.core.js"></script>
<script src="http://jqueryui.com/ui/jquery.ui.widget.js"></script>
<script src="http://jqueryui.com/ui/jquery.ui.datepicker.js"></script>
<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script type="text-x-jquery/template" id="template">
<form action="" method="post">
"${id}" <div class="cellData cellRadios"> <input name="ctype" value="individuel" type="radio" "${in}"/> </div>
</form>
</script>
</head>
<body>
<form action="" method="post">
<input value="Save" type="submit">
</form>
<br><br>
<div id="content"> </div>
然後錯誤控制檯在Firefox中說,語法錯誤的jquery.tmpl.min.js
1號線是從JQuery.tmpl()
的jsfiddle在
是不是
$('#template').tmpl([{ "id" : "555" }, { "in" : "checked" } ]).prependTo('#content');
那是錯的?
更新更新了JSFiddle和Post,失敗的代碼。
@Sandra:你的小提琴工作正常,我看到「555」出現在表格發佈之前... – 2011-05-30 13:40:30
這適用於我 – wong2 2011-05-30 13:42:13
你是對的。這裏發生了什麼!我一定已經簡化了這個問題。 http://jsfiddle.net/Cu5Mj/3/ – 2011-05-30 13:42:34