【问题标题】:Alloy data binding can't find collection合金数据绑定找不到集合
【发布时间】:2014-04-01 23:36:42
【问题描述】:

我正在编写一个简单的应用程序,我想在其中尝试 Alloy 数据绑定,

我已经设置了一个模型区域,我通过在标记中添加它来创建一个单例

<Alloy>
    <Collection id="regions" src="Region" instance="true"/>
    <Window  id="regionWin">

    <TableView id="table" dataCollection="Region">
            <TableViewRow title="{regionName}" />           
    </TableView>

    </Window>
</Alloy>

在控制器中使用模型就可以了

var c = Alloy.createCollection('Region');

var aRegion =  Alloy.createModel('Region', { '_id':'123', 'regionName':'Lazio', 'version': 43});
aRegion.save();

但在 XML 中,也没有将 id 'regions' 或集合名称 'Region' 作为 TableView 属性 'dataCollection' 的值,我得到了结果。

错误总是

找不到变量:RegionScreen.js 中的区域(第 34 行) 或者 找不到变量:RegionScreen.js 中的区域(第 34 行)

有什么建议吗?

【问题讨论】:

    标签: backbone.js data-binding titanium-mobile appcelerator titanium-alloy


    【解决方案1】:

    dataCollection 中,您应该使用$.regions($. 加上您在 Collection 元素中定义的 id)。

    <Alloy>
        <Collection id="regions" src="Region" instance="true"/>
        <Window  id="regionWin">
    
            <TableView id="table" dataCollection="$.regions">
                <TableViewRow title="{regionName}" />           
        </TableView>
    
        </Window>
    </Alloy>
    

    【讨论】:

      猜你喜欢
      • 2012-06-14
      • 2010-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多