下面的代码在这部分代码中抛出错误 - “Microsoft JScript 运行时错误:对象不支持此属性或方法”在 mustache.js 中。 - “
function quote(text) {
var escaped = text.replace(jsCharsRe, function (c) {
return "\\u" + ('0000' + c.charCodeAt(0).toString(16)).slice(-4);
});"
这是我的代码
<%@ Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="VSBackboneDemo._Default" %>
<html>
<head>
<title>VS backbone demo</title>
<script src="Scripts/jquery.min.js" type="text/javascript"></script>
<script src="Scripts/underscore-min.js" type="text/javascript"></script>
<script src="Scripts/backbone-min.js" type="text/javascript"></script>
<script src="http://github.com/janl/mustache.js/raw/master/mustache.js"></script>
<script type="text/javascript">
EmployeeDataView = Backbone.View.extend({
initialize: function () {
this.render();
},
render: function () {
var data = {
employees: [
{ firstName: "Mickey",
lastName: "Mouse",
employeeID: 10000,
jobTitle: "Software Developer"
},
{ firstName: "Donald",
lastName: "Duck",
employeeID: 20000,
jobTitle: "Software Engineer"
},
{ firstName: "Bugs",
lastName: "Bunny",
employeeID: 30000,
jobTitle: "UI tester"
},
]
};
var tpl = "Employees:<ul>{{#employees}}<li>{{firstName}} {{lastName}}" +
"{{employeeID}}{{jobTitle}}</li>{{/employees}}</ul>";
var html = Mustache.to_html(tpl, data);
$('#EmployeeDataContainer').html(html);
}
});
var EmployeeDataView = new EmployeeDataView({ el: $("#EmployeeDataContainer") });
</script>
</head>
<body>
<div id="EmployeeDataContainer">
</div>
</body>
</html>