我正在使用 jsView (v1.0.0-alpha)
我在从视图中获取数据时遇到问题。让我有以下代码。(我在这里创建了一个简化版本http://jsfiddle.net/j5oc0svg/)我试图通过使用占位符名称来获取我之前绑定到视图的数据对象。它总是返回'undertified'。如果我调用 $.view().views 那么我可以看到我之前绑定的视图和数据。
如何使用占位符或(视图名称?)获取绑定到视图的数据?
提前致谢。
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.js"></script>
<base href="http://www.jsviews.com/samples/"/>
<link href="samples.css" rel="stylesheet"/>
<script src="../download/jsviews.js"></script>
</head>
<body>
<table><tbody id="peopleList"></tbody></table>
<script id="personTmpl" type="text/x-jsrender">
<tr>
<td>Name</td>
<td>{{:name}}</td>
</tr>
</script>
<script>
$.ajax({
url: "http://localhost:4728/api/People/,
dataType: 'json'
}).done(function (data) {
if (data!= null) {
var template = $.templates("#personTmpl");
template.link("#peopleList", data);
}
}).fail(function (exception) {
console.log(exception.message);
});
// Let's say this code is in button on click or push subscriber
hub_proxy.client.UpdateSomething = function (someArgs) {
var data = $.view('#peopleList').data; //underfined.
}
</script>
</body>
</html>