2016-12-08 39 views
0

我已经创建了一个函数readAll(),它将数据提取到todos div中,但它没有显示点击函数的数据,但它不工作数据正在成功添加索引数据库但它没有显示。现在,我首先我已经清空表格后,我只是将数据附加到JavaScript的HTML。如何从indexeddb中检索数据并显示在div中

function readAll() { 
    var objectStore = db.transaction("todostore").objectStore("todostore"); 
    $("#todos").empty(); 
    objectStore.openCursor().onsuccess = function(event) { 
    var cursor = event.target.result; 
    if (cursor) { 
    $("#todos").append("<tr><td>" + cursor.key + "</td><td>" + cursor.value.todo + "</td><td><button onclick=\"update('" + cursor.key + "','" + cursor.value.todo + "')\">Update</button></td><td><button onclick=\"removetodo('" + cursor.key + "','" + cursor.value.todo + "')\">Delete</button></td></tr>"); 
    cursor.continue(); 
    } 
}; 
}; 

我现在呼吁点击我打电话的readAll功能

$(".clickme").click(function(){ 
    readAll(); 
}); 

我已经创建div我有现在的我使用一个表头里面的id视图的DIV功能刚刚从附加的JavaScript代码,并填充到HTML

<div id="view"> 
<thead> 
    <tr class="ui-bar-d"> 
    <th data-priority="2">Timestamp</th> 
    <th data-priority="1">To Do</th> 
    <th data-priority="3">Update</th> 
    <th data-priority="4">Delete</th> 
    </tr> 
</thead> 
<tbody id="todos"> 
</tbody> 
</table> 
</div> 
<label for="todo">To Do:</label> 
<input id="todo" type="text"> 
<input id="toprice" type="text"> 
<button class="clickme">clickme</button> 
<button class="ui-shadow ui-btn ui-corner-all" onclick="add()">Add</button> 
+0

你的HTML格式不正确。 – sweaver2112

+0

你能告诉我哪里错了吗 –

+0

失踪

标签看起来像。 – sweaver2112

回答

相关问题