Javascript 未捕获引用错误:$未定义(表)

Javascript 未捕获引用错误:$未定义(表),javascript,titanium-alloy,uncaught-exception,Javascript,Titanium Alloy,Uncaught Exception,我正在尝试使用$.eventslisttable.setData([])重置Alloy中的表;未定义如何获取未捕获的引用错误:$ 该表是在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.cre

我正在尝试使用$.eventslisttable.setData([])重置Alloy中的表;未定义如何获取未捕获的引用错误:$

该表是在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.");
            }
        });
};

因此,答案是取消美元,所以我被引导到了错误的方向


感谢您的帮助。

哪里定义了
$
?您是否忘记在此代码之前包含一个库?没有迹象表明您在提供的任何代码中定义了该名称的变量。您只需尝试对其使用属性。var eventslisttable=tianium.UI.createTableView({});是在alloy.js中定义的。应该全局查看。我的理解是,$是控制器(index.js)处理现有表的方式,而不是删除或重新创建。