我不明白为什么我的情况不起作用
$('#resPage').live('pageshow', function(event) {
application.previousButton();
//get pdf
var text = '';
var value;
var get = application.readGet();
switch(get['id']){
case '1':
var patt = /annales/g;
var cutLen = 20;
break;
case '2':
var patt = /copies/g;
var cutLen = 19;
break;
}
$.ajax({
url:application.api+'/ressources',
success:function(data){
text = "<ul data-role='listview' data-inset='true' >"
data = JSON.parse(data);
for(elem in data.files){
console.log(elem)
console.log(patt.test(data.files[elem]));
if(patt.test(data.files[elem])){
console.log('add');
value = data.files[elem].substr(1);
text += application.textRelLink(value,cutLen);
}
}
text +="</ul>"
$('#resPage .content').html(text);
$('#resPage .content ul').listview();
}
})
});
在我的日志中,我有:
03-02 11:03:14.722: D/CordovaLog(23226): 0
03-02 11:03:14.722: D/CordovaLog(23226): false
03-02 11:03:14.722: D/CordovaLog(23226): 1
03-02 11:03:14.722: D/CordovaLog(23226): false
03-02 11:03:14.722: D/CordovaLog(23226): 2
03-02 11:03:14.722: D/CordovaLog(23226): true
03-02 11:03:14.722: D/CordovaLog(23226): 3
03-02 11:03:14.722: D/CordovaLog(23226): true
03-02 11:03:14.730: D/CordovaLog(23226): 4
03-02 11:03:14.730: D/CordovaLog(23226): true
03-02 11:03:14.730: D/CordovaLog(23226): 5
03-02 11:03:14.745: D/CordovaLog(23226): false
03-02 11:03:14.745: D/CordovaLog(23226): 6
03-02 11:03:14.745: D/CordovaLog(23226): false
但我从来没有在真实时添加
谢谢您的帮助
编辑:
解析前的数据值
03-02 11:25:05.253: D/CordovaLog(23611): {"files":[".\/thumbs\/pdf\/methodo\/sdsdfsd_sdf.pdf",".\/thumbs\/pdf\/methodo\/test!!.pdf",".\/thumbs\/pdf\/annales\/ddfgdfg.pdf",".\/thumbs\/pdf\/annales\/big.pdf",".\/thumbs\/pdf\/annales\/test.pdf",".\/thumbs\/pdf\/copies\/test.pdf",".\/thumbs\/pdf\/poly\/gdfhf.pdf"],"dirs":[".\/thumbs\/pdf\/poly\/",".\/thumbs\/pdf\/copies\/",".\/thumbs\/pdf\/annales\/",".\/thumbs\/pdf\/methodo\/"]}