Reputation: 16
this is my first post here, I'm glade to hear from you :-)
Here's my question, please. In my JqueryMobile web application I've created categories and records. Each category hosts different records.
What I'd like to print out to the user is the number of records that exists in each category.
For selecting the categories I made a normal transaction
function getAll() {
db.transaction(function (transaction) {
transaction.executeSql(("SELECT * FROM tags"), [], getAllSuccess, errorCB);
});
}
function getAllSuccess(tx, result) {
$('#bags_ul').empty();
var output = '';
$.each(result.rows, function (index) {
var row = result.rows.item(index);
output += '<li><a href="#" class="link_to_tag" data-tagnome="' + row['tagnome'] + '" data-tagtipo="' + row['tagtipo'] + '" data-tagid="' + row['tagid'] + '" >' + row['tagnome'] + '</a></li>';
});
$('#bags_ul').html(output);
$('#bags_ul').listview();
$('#bags_ul').listview('refresh');
}
In my example, the function getAll makes the query, and if get success it execute the getAllSuccess function, that fills in the LI fields of my list.
The problem is that I need to create a query inside the $.each() to get the records of the category.
I've tried to execute another transaction within it, and I can successfully get the number of records thorugh the console.log function, but the problem is that I don't know how to pass it to the "mother" function that in facts pushes the HTML to the page.
Could you please help me? As you have understood, I need to know the "logic" that is behind this. I really do thank you very much for your help.
Marco
Upvotes: 0
Views: 404
Reputation: 5168
You could chain the callbacks yourself or use JQuery Deferred.
Upvotes: 1