Titanium Alloy无法访问第三级嵌套对象

时间:2015-07-02 14:02:19

标签: javascript titanium titanium-alloy

我遇到了钛合金的问题。我似乎无法访问从控制器在XML中声明的3d级嵌套对象。

这是XML中的布局:

<Alloy>
    <Collection src="reportDetails"/>
    <Window class="container" title="Update Report Details" onClose="cleanup" >

        <View id="labels">          
            <TextArea id="jobTitle" class="title bold" editable="false"></TextArea>         
            <View class="jobTitleSecondPart" >
                <Label class='bold'>last date od service: </Label>
                <Label id="jobDate" class="stickLeft"></Label>
                <Label class='bold'>Job ID: #</Label>
                <Label id="jobId" class="stickLeft"></Label>
            </View>
        </View>
        <ActivityIndicator id="busy"></ActivityIndicator>
        <View height="Titanium.UI.FILL">
            <ScrollView  id="scrollIns" layout="vertical" dataCollection="reportDetails" dataFilter="filterFunction" height="Titanium.UI.FILL">
                <View id="instruction"> <!-- ***I am trying to access this object in the controlle***r -->
                    <Label class="title bold black">Agent Instructions :</Label>
                    <Label platform="android" id="jobInstruction" html="{agentInstructions}" class="black"   height="Titanium.UI.SIZE" />
                    <WebView platform="ios" id="jobInstruction" html="{agentInstructions}" class="black" touchEnabled="false" height="Titanium.UI.SIZE" />
                </View>
                <View id="comment">
                    <Label class="title bold black">Agent Comment :</Label>
                    <Label id="jobComment" class="black" text="{reportComment}"></Label>
                </View>
                <Require src="reportImageGallery" images="{images}"/>
            </ScrollView>
            <View id="buttons">
                <Button id="btnInsert" class="bold" onClick="showInsertReport">Insert Update Reports</Button>
            </View>
        </View>

    </Window>
</Alloy>

这是来自控制器的代码行:

$。instruction.visible = false;

这就是它给我的错误:

message =“undefined不是对象(评估'$ .instruction.visible = false')”;

1 个答案:

答案 0 :(得分:1)

@Turtle是正确的,数据绑定的父元素(使用dataCollection)内的ID不能用于通过$.<id>到达它们,因为会有多个实例。