什么'这个JQuery有问题
What's wrong with this JQuery?
当我进行时
$(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
http://jsfiddle.net/Cu5Mj/4/
是吗
$('#template').tmpl([{ "id" : "555" }, { "in" : "checked" } ]).prependTo('#content');
这是错的吗?
更新更新JSFiddle并发布失败的代码。
我在您的HTML中更改了以下内容:
<script type="text/x-jquery-tmpl" id="template">
<form action="" method="post">
"${Id}" <div class="cellData cellRadios"> <input name="ctype" value="individuel" type="radio" ${In} /> </div>
</form>
</script>
和您的JavaScript:
$(document).ready(function(){
$('form').live('submit', function(){
$('#template').tmpl({ "Id" : "555","In" : "checked" }).prependTo('#content');
return false;
});
});
现在它对我有效。
我认为问题在于模板变量名,我将其大写,模板数据是一个由2个对象组成的数组,而不是一个简单的对象。(还稍微更改了模板脚本MIME。)
相关文章:
- Html、css和jQuery.我的代码有问题
- Jquery中的mousemove和图像有问题
- jQuery在函数AJAX函数内部的全局变量有问题
- 有问题的jQuery导航栏弹出窗口
- I'我对jquery-ui-resizable有问题.我想在4个相等的间隔内减小和增加宽度
- jQuery悬停函数有问题
- jquery动态添加有问题的行
- JQuery -有Internet Explorer的动态表问题
- Ajax/PythonBottle/Jquery/JSON传递参数有问题
- 当控制器与视图中的数据有问题时,MVC打开jquery对话框
- 通过jQuery ajax调用JS函数有问题
- 使用jquery dataTable删除html表行有问题
- 在一个页面上使用多个jQuery UI控件实例有问题.手风琴控件的多种用途
- Jquery菜单使用slidetoggle()略有问题
- JQuery -有办法解决这个问题吗?
- 找到,替换jquery..搜索词数组有问题
- 在jQuery中使用setTimeout对函数排序有问题
- jQuery新手:这个代码示例有问题
- 什么'这个JQuery有问题
- 使用jquery有问题.验证器和格式散列一起工作