javascript - Put HTML Divs Into PouchDB -
i want put html div (and contents) json object , save pouchdb database.
my div looks this:
<div class="easel"> <div class="square" style="background-color: white;"></div> <div class="square" style="background-color: white;"></div> <div class="square" style="background-color: rgb(85, 222, 25);"></div><div class="square" style="background-color: white;"></div> <div class="square" style="background-color: white;"></div> <div class="square" style="background-color: white;"></div> <div class="square" style="background-color: white;"></div> <div class="square" style="background-color: rgb(164, 101, 52);"></div><div class="square" style="background-color: white;"></div> <div class="square" style="background-color: white;"></div> <div class="square" style="background-color: white;"></div> <div class="square" style="background-color: rgb(214, 15, 77);"></div><div class="square" style="background-color: white;"></div> <div class="square" style="background-color: white;"></div> <div class="square" style="background-color: white;"></div> </div>
i wrote function this:
window.saveboard = function() { var db = new pouchdb('tiles'); var remotecouch = false; var current_layout = $('.easel'); var new_board = { _id: new date().toisostring(), board: current_layout } db.put(new_board, function callback(err, result) { if(!err) { console.log("successfully saved new board."); } }) }
but doesn't seem doing want , i'm getting error in console: uncaught datacloneerror: failed execute 'put' on 'idbobjectstore': object not cloned.
what need store div info in order later feed page?
you can't store html elements directly in pouchdb; can store straight-up json. need convert div data structure format before storing.
Comments
Post a Comment