I am currently making a list of items of downloaded and not downloaded files with jQuery mobile and Phonegap.
Everything seems to work OK, but I am simply unable to set value to my attribute data-status
.
I am looping through a list of filenames in a JSON to check if they exists, and this works well. This is what happens for each file:
var $li;
$li = $("<li><a href='#' data-status='Not downloaded'>"+val.title+"</a></li>");
Then if the file is found on the system:
$li.find("a").on("click", function(){ openPdf(val.title); }); // a click handler added
$li.find("a").setAttribute('data-status', 'Downloaded'); // This is where something is wrong.
For each file, the $li is appended to the ListView. Then after the whole loop process:
$("#linkList")
.listview({
autodividers: true,
autodividersSelector: function (li) {
var out = li.find('a').data("status");
return out;
}
}).listview('refresh');
So, any ideas why the attribute data-status
isn't being changed to "Downloaded"?