0

I am using JQM and building a large lists of contacts from a webSQL database. Currently the process is painfully slow so I am trying to use a template to see how this affects performance.

I cannot figure out how to use a Jquery template with a WebSQL ResulSet.

This is the code so far:

function (tx, result)
{
    var markup = '<li><a href="#contact">${result.Name}</a></li>';
    $.template("contactTemplate", markup);
    $.tmpl("contactTemplate", /* What goes here? */).appendTo($list);
}
Jon Wells
  • 4,191
  • 9
  • 40
  • 69

1 Answers1

0

Ok, Jquery template expects an array. Therefore the following works:

var contacts = [];

for (i = 0; i < result.rows.length; i++)
{
    contacts.push(result.rows.item(i));
}

var markup = '<li><a href="#contact">${Name}</a></li>';
$.template("contactTemplate", markup);

$.tmpl("contactTemplate", contacts).appendTo($list);

This approach has very little impact on performance. Building the list is equally slow.

Jon Wells
  • 4,191
  • 9
  • 40
  • 69