0
我試圖通過點擊事件瀏覽我的音樂目錄 - 我可以獲得原始列表視圖,顯示可以開始,單擊事件將向下鑽取到下一個目錄,但在第三次單擊我的索引位置不斷返回原始directoryEntry對象的完整路徑。Phonegap:通過目錄瀏覽,索引位置不正確
JS
function readerSuccess(entries) {
$("#test").empty();
for (i=0;i<entries.length;i++){
$("#test").append("<li>"+entries[i].name+"</li>");
}
$("#test").listview("refresh");
ListClickHandler(entries);
}
var ListClickHandler = function(something){
$(document).on("click","#test li",function(event){
var mylistname = $(this).text();
var index = $("#test li").index(this);
var listpath = something[index].fullPath; //this is causing the problem. entries never changes.
alert(index);
if(something[index].isFile ===true)
{
$("#test").empty();
alert("this is a file");
}
else if(something[index].isDirectory===true)
{
var directoryentry = new DirectoryEntry(mylistname,listpath);
var directoryreader = directoryentry.createReader();
directoryreader.readEntries(readerSuccess,fail);
//alert("this is a directory"+mylistname+listpath);
}
});
}