2016-12-08 4 views
0

todos divにデータをフェッチしているが、クリック機能でデータを表示していないが、データが正常に追加されているreadAll()関数を作成しました。インデックスdbが表示されていません。今私は最初に私はちょうど私はちょうどjavascriptからhtmlにデータを追加しているテーブルを空にしている。indexeddbからデータを取り出してdivに表示する方法

今私はちょうど私が今私は、私はテーブルのヘッドを使用していdivの内部IDビューのdiv要素を作成している

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

READALL関数を呼び出していますクリックで関数を呼び出しています

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(); 
    } 
}; 
}; 

ただのJavaScriptのコードを追加し、HTMLに移入IDBとして

<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

答えて

関連する問題