我需要从java脚本文件中获取textarea值。下面是我的代码,
单击index.xml中的按钮,控件应转至getPrivacy_policy()并显示隐私页面。
Privacy.xml
<Alloy>
<Window id="privacyWin" title="Plan India" platform="android,ios">
<View id="header">
<Label id="title">Privacy Policy</Label>
</View>
<TextArea id="privacyID" suppressReturn="false"></TextArea>
</Window>
</Alloy>
index.js
function getPrivacy_policy()
{
var privacy_string = "some long text...";
return privacy_string;
var privacyPolicy = Alloy.createController('privacy').getView();
privacyPolicy.open();
}
如何在textarea中显示位于privacy.xml中的privacy_string
值?
请注意,(XML和Js)都是不同的文件。
答案 0 :(得分:0)
在Alloy中,您可以按ID访问视图元素,因此您可以执行以下操作:
$.privacyID.value
将返回TextArea
中的文本