On the HTML side:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="Content-Language" content="en" />
<style>
p.serif{font-family:"Times New Roman",Times,serif;}
p.sansserif{font-family:Arial,Helvetica,sans-serif;}
</style>
<link rel="stylesheet" href="style/main.css" type="text/css">
<title>PDS Jobs</title>
</head>
<script src="/_utils/script/sha1.js"></script>
<script src="/_utils/script/json2.js"></script>
<script src="/_utils/script/jquery.js"></script>
<script src="/_utils/script/jquery.couch.js"></script>
<script src="vendor/couchapp/jquery.couchLogin.js"></script>
<script src="vendor/couchapp/jquery.couchProfile.js"></script>
<script src="script/turboapp.js"></script>
The following code is intended to be a couchapp, and is part of "turboapp.js":
db = $.couch.db("testdb3");
var PMdata = new Object();
for (i in values) {
PMdata[values[i]] = new Array();
}
db.view("turbologviewer/pm", {
reduce : false,
success : function(data) {
$(data.rows).each( function (index, item) {
if (PMdata.hasOwnProperty(item.key[0])) {
if (item.key[1] == 0) {
PMdata[item.key[0]][0] = item.value;
} else if (item.key[1] == 1) {
PMdata[item.key[0]][1] = item.value;
}
}
});
}
});
for (i in values) {
alert("Job " + values[i] + "\n" +
" Values1: " + PMdata[values[i]][0] + "\n" +
" Values2: " + PMdata[values[i]][1] + "\n");
}
Is intended to take selected keys stored in "values". For these keys data values from a view are supposed to be stored in PMdata. Effectively this code is joining the data of two documents. Any suggestions on how to do this would also be greatly appreciated.
When I run this normally, with two entries in "values", I get "Values1: undefined \n Values2: undefined \n" for the first alert, and good data for the second alert.
When I run this under the firefox debugger, and I set a breakpoint at the alert, both alerts show perfectly good data!
What is going on?
Thanks, Gustavo Tellez