我正在尝试使用$ .eventslisttable.setData([])重置Alloy中的表;我怎么得到Uncaught ReferenceError:$未定义。
该表是在alloy.js下创建的,我正在尝试从index.js完成重置
alloy.js
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title: 'Tab 1',
backgroundColor: '#fff'
});
var tab1 = Titanium.UI.createTab({
icon: 'KS_nav_views.png',
title: 'Tab 1',
window: win1
});
//var button = Titanium.UI.createButton({
// color: '#999',
// title: 'Show Modal Window',
// width: 180,
// height: 35
//});
//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({
title: 'Tab 2',
backgroundColor: '#fff'
});
var tab2 = Titanium.UI.createTab({
icon: 'KS_nav_ui.png',
title: 'Tab 2',
window: win2
});
//
// add events table
//
var eventslisttable = Titanium.UI.createTableView({});
win2.add(eventslisttable);
//
//watchbutton setup
//
var buttonShowmap = Titanium.UI.createButton({
title: 'Showmap',
top: 10,
width: 100,
height: 50
});
var buttonshowEventslist = Titanium.UI.createButton({
title: 'showEventslist',
top: 60,
width: 100,
height: 50
});
win2.add(buttonShowmap);
win2.add(buttonshowEventslist);
//
// add tabs
//
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
//
// open tab group
//
tabGroup.open({navBarHidden:true});
index.js
function showMapview(e) {
console.log("showMapview");
// wipe list view
$.eventslisttable.setData([]);
console.log("showMapview Internal");
// Add the mapview
var mapview = Titanium.Map.createView({
mapType : Titanium.Map.STANDARD_TYPE,
region : {
latitude : Alloy.Globals.LAT,
longitude : Alloy.Globals.LNG,
latitudeDelta : 0.01,
longitudeDelta : 0.01
},
animate : true,
regionFit : true,
userLocation : true,
height : 200
});
// Insert a row in first index of the table that has the mapview in it
var row = Ti.UI.createTableViewRow();
row.add(mapview);
$.eventslisttable.insertRowBefore(1, row);
// Handle click events on any annotations on this map.
mapview.addEventListener('click', function(evt) {
Ti.API.info("Annotation " + evt.title + " clicked, id: " + evt.annotation.myid);
// Check for all of the possible names that clicksouce
// can report for the left button/view
if (evt.clicksource == 'leftButton' || evt.clicksource == 'leftPane' || evt.clicksource == 'leftView') {
Ti.API.info("Annotation " + evt.title + ", left button clicked.");
}
});
};
答案 0 :(得分:0)
所以答案是删除$所以我被误导了。
感谢您的帮助。