0
Chrome App을 만들고 PouchDB를 사용하고 있습니다 (처음 사용). DevTools의 Resources 패널에서 IndexedDB를 실행하십시오. 문제는 PouchDB에 데이터를 추가하고 업데이트하는 것입니다. 작동하지 않습니다. (app_jr.js) HTML 파일에 대한Chrome 앱용 PouchDB
var saveregister, JrRegisterObj, pn;
JrRegisterObj = function (databasename, remoteorigin){
'use strict';
Object.defineProperty(this, 'pdb', {writable:true});
Object.defineProperty(this, 'remote', {writable:true});
Object.defineProperty(this, 'formobject', {writable:true});
Object.defineProperty(this, 'errordialog', {writable: true});
this.pdb = new PouchDB(databasename);
this.remote = remoteorigin + '/'+databasename;
};
saveregister = function(event) {
var n = {};
if(!this.formobject._id.value){
n._id = new Date().getTime() + '';
} else {
n._id = this.formobject._id.value;
}
n.jr_u_ubn = (this.formobject.jr_u_ubn.value === '') ? '' : this.formobject.jr_u_ubn.value;
n.jr_u_name = (this.formobject.jr_u_name.value === '') ? '' : this.formobject.jr_u_name.value;
n.jr_u_branch = (this.formobject.jr_u_branch.value === '') ? '' : this.formobject.jr_u_branch.value;
this.pdb.put(n, function(error, response){
if(error){
console.log(error);
return;
} else if(response && response.ok){
}
});
}
pn = new JrRegisterObj('jr_register');
pn.formobject = document.getElementById('jr_reg_form');
pn.errordialog = document.getElementById('errordialog');
pn.formobject.addEventListener('submit', function (e){
e.preventDefault();
pn.saveregister();
});
: (주니어 register.html)
<!DOCTYPE html>
<html lang="en-us" manifest="jr_register.manifest">
<head>
<title>Junior Registration</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="header">
<h1>Junior Register</h1>
</div>
<section id = "add_jr">
<form class="pure-form" id = "jr_reg_form" method="post">
<fieldset>
<legend>Register</legend>
<table align="center">
<tr>
<input type="hidden" id="_rev" name="_rev" value="">
<input type="hidden" id="_id" name="_id" value="">
<td>UBN:</td>
<td><input type="text" id="jr_u_ubn" name_u="jr_u_ubn"></td>
</tr>
<tr>
<td>Name:</td>
<td><input type="text" id="jr_u_name" name="jr_u_name"></td>
</tr>
<tr>
<td>Branch:</td>
<td><input type="text" id="jr_u_branch" name="jr_u_branch"></td>
</tr>
</table>
<button type="submit" id="jr_register_btn" class="pure-button pure-button-primary">Register</button>
</fieldset>
</form>
</section>
<script type="text/javascript" src="js/app_jr.js"></script>
<script type="text/javascript" src="js/pouchdb-nightly.min.js"></script>
<script type="text/javascript" src="js/pouchdb.mapreduce.noeval.js"> </script>
<script type="text/javascript" src="js/jr-register.js"></script>
</body>
</html>
내가 here
도움을 얻었다 여기 코드입니다나는 이것에 대한 연구에 정말로 노력을 기울이고 있지만, 해결책을 찾지 마라. 도와 주셔서 감사합니다.