我遇到了鈦合金的問題。我似乎無法訪問在控制器的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;
,這是錯誤它給了我:
消息= 「undefined是不是一個對象(計算 '$ .instruction.visible =假')」;
我可以用你的代碼思考的一個問題是你正在使用scrollview的集合;所以基本上,scrollview內的內容循環的次數與reportDetails模型中的行次數相同。因此'id =「指令」'也是多次創建的(即rows.length);所以當你試圖在控制器中獲取這個ID時,它可能會感到困惑,因爲一個XML文件應該有唯一的ID。 – turtle
如果你能解釋你的業務邏輯;我會盡力幫忙。 – turtle