我正在尝试使用第二次按下后退按钮时使用后退按钮关闭窗口。在我的代码中,我正在运行一个 yql 查询并将从查询中获得的数据插入到行中,然后将行添加到表中。我不明白为什么我需要按两次后退按钮,请帮忙。在此先感谢以下是我的代码:
var DetailWin = Titanium.UI.currentWindow;
var information = new Array("Company Name: ", "Company Location:", "Position Type:", "Employee Type:", "Minimum Education:", "Vacancy:", "Gender:", "Salary:");
var var1=Ti.App.lurl;
var rowData = [];
Titanium.Yahoo.yql('select * from html where url="' + var1 + '" and xpath="//p/span" limit 8', function(e) {
var results = e.data.span;
for (var i = 0; i < results.length; i++) {
var rss = results[i];
var rssRow = Titanium.UI.createTableViewRow({
top : 200,
height : 45,
className : 'rssrow'
});
var titleLabel = Titanium.UI.createLabel({
text : information[i] + " " + rss,
font : {
fontSize : 16,
fontWeight : 'bold'
},
width : 'auto',
top : 5,
left : 40,
height : 20,
color:'black'
});
rssRow.add(titleLabel);
rowData.push(rssRow);
};
jobdetail.setData(rowData);
});
var jobdetail = Titanium.UI.createTableView({
top:'12%',
});
DetailWin.add(jobdetail);
var backbut = Titanium.UI.createButton({
title:'Back',
top:'2%',
width:'20%',
height:'auto',
left:'5%'
});
backbut.addEventListener('click', function(){
DetailWin.close();
});
DetailWin.add(backbut);