[ALOY-1283] ActionView views with an ID cannot be found under $ because they are created after merge
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-10-16T00:38:14.000+0000 |
Affected Version/s | Alloy 1.6.2, alloy 1.7.17 |
Fix Version/s | Release 5.1.0, alloy 1.7.18 |
Components | XML |
Labels | n/a |
Reporter | Fokke Zandbergen |
Assignee | Feon Sua Xin Miao |
Created | 2015-06-25T10:16:10.000+0000 |
Updated | 2015-11-10T23:35:36.000+0000 |
Description
ALOY-1175 fixed this issue for IDs set on
<MenuItem>
but it is still an issue for views under <ActionView>
. Because they are created after the controller merges $.__views
with $
you cannot access the views via $.<id>
.
*index.xml*
<Alloy>
<Window>
<Menu>
<MenuItem title="Open" showAsAction="Titanium.Android.SHOW_AS_ACTION_ALWAYS">
<ActionView>
<View id="myViewInActionView" backgroundColor="red">
<Button onClick="changeColor">Change Color</Button>
</View>
</ActionView>
</MenuItem>
</Menu>
</Window>
</Alloy>
*index.js*
$.index.open();
function changeColor() {
$.myViewInActionView.backgroundColor = 'green';
}
PR: https://github.com/appcelerator/alloy/pull/732
[~fmiao] I updated the test case to make it simpler but the PR doesn't fix it. The above - with your PR - compiles to:
And since
onCreateOptionsMenu
executes _after__.extend($, $.__views);
the above has no effect anymore on$
. So whatever happens insideonCreateOptionsMenu
needs to write directly to$
or merge its views with it at the end.It's interesting that the generated code is different for me.
Sorry [~fmiao], my fault.. patched the wrong (global) alloy. Verified fixed.
PR merged.
Verified fixed, using: MacOS 10.11.2 (15C31f) Studio 4.4.0.201511040454 Ti SDK 5.1.0.v20151110110428 Appc NPM 4.2.1 Appc CLI 5.1.0-45 Ti CLI 5.0.5 Alloy 1.7.24 Arrow 1.3.19 Xcode 7.2 (7C46t) Node v0.12.7 Java 1.7.0_80 production ActionViews can be accessed with $.