Appcelerator 数据绑定小部件和点击事件
Appcelerator data-binding widgets and click event
我正在尝试构建以下日历小部件
widgets/com.ui.calendar/views/widget.xml
<Alloy>
<Collection src="CalendarDay" instance="true" id="dateColl"></Collection>
<View id="calHolder" height="Ti.UI.SIZE" layout="vertical">
<ScrollView id="calBody" layout="horizontal" height="Ti.UI.SIZE" width="Ti.UI.FILL" dataCollection="$.dateColl">
<Widget src="com.ui.calendar" name="daytile"></Widget>
</ScrollView>
</View>
widgets/com.ui.calendar/views/daytile.xml
<Alloy>
<View id="calDayTile" layout="vertical" onClick="selectMe" bindId="{FullDate}">
<Label id="calDayTileDay" text="{day}" width="Ti.UI.FILL"></Label>
<Label id="calDayTileDate" text="{date}" width="Ti.UI.FILL"></Label>
</View>
这使 UI 正常,如上面的屏幕截图所示。
现在我想绑定一个点击处理程序,这样当一天被点击时,我可以显示该图块为选中状态并将所选日期传递给父控制器。
<Widget src="com.ui.calendar" name="daytile" onClick="dateSelected"></Widget>
我最终遇到以下错误:
[ERROR] : Script Error {
[ERROR] : column = 18;
[ERROR] : line = 34;
[ERROR] : message = "__alloyId213.getViewEx({\n recurse: true\n }).on is not a function. (In '__alloyId213.getViewEx({\n recurse: true\n }).on(\"click\", dateSelected)', '__alloyId213.getViewEx({\n recurse: true\n }).on' is undefined)";
[ERROR] : sourceURL = "file:///Users/npatel/Library/Developer/CoreSimulator/Devices/A7BDE792-2DA3-4B3E-807B-505F4212AE96/data/Containers/Bundle/Application/8826886B-22B4-4586-A193-75D5EB3F204A/FieldServiceMobilityStage.app/alloy/widgets/com.ui.calendar/controllers/widget.js";
[ERROR] : }
关于在这种情况下如何处理事件的任何指示?
我将事件处理移到了父容器中。
<ScrollView id="calBody" layout="horizontal" height="Ti.UI.SIZE" width="Ti.UI.FILL" onDateselected="dateSelected" dataCollection="$.dateColl" dataFunction="refreshCalendar">
我正在尝试构建以下日历小部件
widgets/com.ui.calendar/views/widget.xml
<Alloy>
<Collection src="CalendarDay" instance="true" id="dateColl"></Collection>
<View id="calHolder" height="Ti.UI.SIZE" layout="vertical">
<ScrollView id="calBody" layout="horizontal" height="Ti.UI.SIZE" width="Ti.UI.FILL" dataCollection="$.dateColl">
<Widget src="com.ui.calendar" name="daytile"></Widget>
</ScrollView>
</View>
widgets/com.ui.calendar/views/daytile.xml
<Alloy>
<View id="calDayTile" layout="vertical" onClick="selectMe" bindId="{FullDate}">
<Label id="calDayTileDay" text="{day}" width="Ti.UI.FILL"></Label>
<Label id="calDayTileDate" text="{date}" width="Ti.UI.FILL"></Label>
</View>
这使 UI 正常,如上面的屏幕截图所示。
现在我想绑定一个点击处理程序,这样当一天被点击时,我可以显示该图块为选中状态并将所选日期传递给父控制器。
<Widget src="com.ui.calendar" name="daytile" onClick="dateSelected"></Widget>
我最终遇到以下错误:
[ERROR] : Script Error {
[ERROR] : column = 18;
[ERROR] : line = 34;
[ERROR] : message = "__alloyId213.getViewEx({\n recurse: true\n }).on is not a function. (In '__alloyId213.getViewEx({\n recurse: true\n }).on(\"click\", dateSelected)', '__alloyId213.getViewEx({\n recurse: true\n }).on' is undefined)";
[ERROR] : sourceURL = "file:///Users/npatel/Library/Developer/CoreSimulator/Devices/A7BDE792-2DA3-4B3E-807B-505F4212AE96/data/Containers/Bundle/Application/8826886B-22B4-4586-A193-75D5EB3F204A/FieldServiceMobilityStage.app/alloy/widgets/com.ui.calendar/controllers/widget.js";
[ERROR] : }
关于在这种情况下如何处理事件的任何指示?
我将事件处理移到了父容器中。
<ScrollView id="calBody" layout="horizontal" height="Ti.UI.SIZE" width="Ti.UI.FILL" onDateselected="dateSelected" dataCollection="$.dateColl" dataFunction="refreshCalendar">