brainwarped
Programmer
Hi,
Please help me with the Javascript code below. The goal is to use JQuery and JQTouch to query a local database for all entries and then append them to the "#dates ul" element using the hidden entryTemplate HTML for structure. (Additional information can be found in the tutorial: and the next chapter.)
After extensive testing of the code, I believe the loop in the refreshEntries function is not running. I have tested the code in the desktop and mobile safari, and know that the database is recording entries, but the refreshEntries function is not displaying the entries. Please let me know if I have made a coding error.
The Javascript code that that performs the operation is below:
function refreshEntries() {
$('#dates ul li:gt(0)').remove();
db.transaction(
function(transaction) {
transaction.executeSql(
'SELECT * FROM entries ORDER BY id;',
function (transaction, result) {
for (var i=0; i < result.rows.length; i++) {
var row = result.rows.item(i);
var newEntryRow = $('#entryTemplate').clone();
newEntryRow.removeAttr('id');
newEntryRow.removeAttr('style');
newEntryRow.data('entryId', row.id);
newEntryRow.appendTo('#scans ul');
newEntryRow.find('.label').text(row.barcode1);
newEntryRow.find('.pack').text(row.packsAvailable);
newEntryRow.find('.delete').click(function() {
var clickedEntry = $(this).parent();
var clickedEntryId = clickedEntry.data('entryId');
deleteEntryById(clickedEntryId);
clickedEntry.slideUp();
});
}
},
errorHandler
);
}
);
}
Please help me with the Javascript code below. The goal is to use JQuery and JQTouch to query a local database for all entries and then append them to the "#dates ul" element using the hidden entryTemplate HTML for structure. (Additional information can be found in the tutorial: and the next chapter.)
After extensive testing of the code, I believe the loop in the refreshEntries function is not running. I have tested the code in the desktop and mobile safari, and know that the database is recording entries, but the refreshEntries function is not displaying the entries. Please let me know if I have made a coding error.
The Javascript code that that performs the operation is below:
function refreshEntries() {
$('#dates ul li:gt(0)').remove();
db.transaction(
function(transaction) {
transaction.executeSql(
'SELECT * FROM entries ORDER BY id;',
function (transaction, result) {
for (var i=0; i < result.rows.length; i++) {
var row = result.rows.item(i);
var newEntryRow = $('#entryTemplate').clone();
newEntryRow.removeAttr('id');
newEntryRow.removeAttr('style');
newEntryRow.data('entryId', row.id);
newEntryRow.appendTo('#scans ul');
newEntryRow.find('.label').text(row.barcode1);
newEntryRow.find('.pack').text(row.packsAvailable);
newEntryRow.find('.delete').click(function() {
var clickedEntry = $(this).parent();
var clickedEntryId = clickedEntry.data('entryId');
deleteEntryById(clickedEntryId);
clickedEntry.slideUp();
});
}
},
errorHandler
);
}
);
}