我正在关注此Cordova tutorial。
我在handlebars.js教程中,当我在我的设备上运行时,我得到了空白的白色屏幕。你能帮忙发现代码中缺少的内容吗?
这是索引html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link href="assets/ratchet/css/ratchet.css" rel="stylesheet">
<link href="assets/css/styles.css" rel="stylesheet">
</head>
<body>
<script id="home-tpl" type="text/template">
<header class="bar bar-nav">
<h1 class="title">Directory</h1>
</header>
<div class="bar bar-standard bar-header-secondary">
<input class='search-key' type="search"/>
</div>
<div class="content"></div>
</script>
<script id="employee-list-tpl" type="text/template">
<ul class="table-view">
{{#each this}}
<li class="table-view-cell media">
<a href="#employees/{{ id }}">
<img class="media-object pull-left" src="assets/pics/{{pic}}">
<div class="media-body">
{{firstName}} {{lastName}}
<p>{{title}}</p>
</div>
</a>
</li>
{{/each}}
</ul>
</script>
<script src="lib/handlebars.js"></script>
<script src="lib/jquery.js"></script>
<script src="js/services/localstorage/EmployeeService.js"></script>
<script src="js/app.js"></script>
<script src="cordova.js"></script>
<script src="lib/fastclick.js"></script>
</body>
</html>
这是App.Js
// We use an "Immediate Function" to initialize the application to avoid leaving anything behind in the global scope
(function() {
/* ---------------------------------- Local Variables ---------------------------------- */
var service = new EmployeeService();
var homeTpl = Handlebars.compile($("#home-tpl").html());
var employeeListTpl = Handlebars.compile("#employee-list-tpl").html());
service.initialize().done(function() {
renderHomeView();
});
/* --------------------------------- Event Registration -------------------------------- */
document.addEventListener('deviceready', function () {
if (navigator.notification) { // Override default HTML alert with native dialog
window.alert = function(message) {
navigator.notification.alert(
message, // message
null, // callback
"Workshop", // title
'OK' // buttonName
);
};
}
FastClick.attach(document.body);
}, false);
/* ---------------------------------- Local Functions ---------------------------------- */
function findByName() {
service.findByName($('.search-key').val()).done(function (employees) {
$('.content').html(employeeListTpl(employees));
});
}
function renderHomeView() {
$('body').html(homeTpl());
$('.search-key').on('keyup', findByName);
}
}());