我的jquery mobile 1.4.5 index.html页面中有一个表:
<table id="summary-table" data-role="table"
data-mode="columntoggle" class="ui-responsive table-stroke">
<thead>
...
</thead>
<tbody>
...
</tbody>
</table>
我的index.js文件中也有一些javascript:
$(document).on("touchend", "#listButton", function(e) {
e.preventDefault();
db.allDocs({include_docs: true, attachments: true}, function(err, response) {
for (var record in response) {
$("#summary-table tbody").append(
"<tr>"+
"<th>" + record.a + "</th>"+
"<td>" + record.b + "</td>"+
"</tr>");
}
});
这会起作用,但似乎不是分离问题的好方法,因为我在我的javascript中嵌入了html。
使用jquery mobile分离关注点的最佳做法是什么?
答案 0 :(得分:0)
最后,我遵循了示例项目https://github.com/hazems/cordova-mega-app
中使用的模式该项目将javascript代码分为以下几个方面: