[ALOY-913] Error TextField on addEventListener on dataCollection
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2014-08-26T18:23:47.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Alloy 1.5.0 |
| Components | Models, XML |
| Labels | ios, qe-manualtest |
| Reporter | Afranio Martins |
| Assignee | Feon Sua Xin Miao |
| Created | 2013-12-24T14:42:05.000+0000 |
| Updated | 2014-08-27T23:22:27.000+0000 |
Description
index.xml:
<Alloy>
<Collection id="library" src="library" instance="true"/>
<Window id="index">
<View dataCollection="$.library">
<Label text="{name}" />
<TextField text="Quantity" onBlur="setQuantity" />
</View>
<Window>
</Alloy>
Add a viewMore function in index.js:
function setQuantity(event) {
alert('View more');
}
$.index.open();
Results Alloy output
for (var i = 0; len > i; i++) {
//...
var __alloyId219 = Ti.UI.createTextField({});
setQuantity ? $.__views.__alloyId211.addEventListener("blur", setQuantity) : __defers["$.__views.__alloyId211!blur!setQuantity"] = true;
//...
}
A solution that works, but do not know if it is correct
{color:red} File Alloy/commands/compile/parsers/Ti.UI.TextField.js// Update the parsing state return { parent: {}, styles: state.styles, code: code };// Update the parsing state nodeState.styles = state.styles; nodeState.code = code; return nodeState; ``` :DFix for one is probably going to solve the other
PR: https://github.com/appcelerator/alloy/pull/419 Test app: https://github.com/feons/alloy/tree/ALOY-913/test/apps/testing/ALOY-913 Functional Test: 1. Run the test app on iOS 2. Check Resources/iphone/alloy/controllers/index.js:
3. The event listener is attached to the right object *__alloyId6.*37 var __alloyId6 = Ti.UI.createTextField({ 38 right: 0, 39 height: "50dp", 40 width: "100dp", 41 borderColor: "#ccc", 42 borderWidth: 1, 43 value: "1", 44 color: "#000", 45 text: "Quantity" 46 }); 47 __alloyId4.add(__alloyId6); 48 setQuantity ? __alloyId6.addEventListener("focus", setQuantity) : __defers["__alloyId6!focus!setQuantity"] = true;PR tested and merged
Event listener seems to be attached correctly, however the sample app presents a couple of issues. 1. In Styles folder, instead of app.tss , there is an app.js , which in studio is generating an error message. 2. Sample is not runnable on Android as in the index.xml the
Master PR: https://github.com/appcelerator/alloy/pull/525 1_5_X PR: https://github.com/appcelerator/alloy/pull/526 Updated test app.
[~skypanther] would you review & merge those PRs?
I've merged the PR against master. However the PR on 1_5_X includes extraneous changes. It will need to be resubmitted.
[~skypanther] Here's the new PR. New PR for 1_5_X: https://github.com/appcelerator/alloy/pull/529
Both PRs merged
Verified fix on: Mac OSX 10.9.4 Appcelerator Studio, build: 3.4.0.201408270900 Titanium SDK build: 3.4.0.v20140827134113 Titanium CLI, build: 3.4.0-dev Alloy: 1.5.0-dev iOS Device 5S (7.1.1) Android Emulator 4.4.2 Event listener is attached correctly as per Federico's comment. Sample is now runnable on Android as