JQuery - $ .each in SqlResultsetRowList in Safari / iOS

I am trying to use $ .each to speed up the iteration of SqlResultsetRowList, where I am currently using a For loop. Here is the new code -

localDB.transaction(function(transaction){ transaction.executeSql(query, [val], function(transaction, results) { var rows = results.rows; $.each(rows, function(i) { var row = results.rows.item(i); }); } ) });

The problem ireturns as not an index, but the string "length" and, obviously, breaks at this point.

I did some testing and it works in Chrome. Chrome treats SqlResultsetRowList as an array, but Safari does not. Is it possible to convert the result set to an array so that Safari can iterate through $ .each?

+4
source share
2 answers

, - , , Safari Mobile Safari, , . , , .

Safari SqlResultsetRowList , .

var contacts = [];

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

, , , contacts $.each.

$.each(contacts, function() {
    var ID = this.Contact_ID;
    //more logic here
});
+9

$.each(rows, function(i, val) {
    var row = results.rows.item[i];
    console.log('index:' +i+ '    val:' +val);
});
0

Source: https://habr.com/ru/post/1589284/


All Articles