Titanium JIRA Archive
Alloy (ALOY)

[ALOY-913] Error TextField on addEventListener on dataCollection

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-08-26T18:23:47.000+0000
Affected Version/sn/a
Fix Version/sAlloy 1.5.0
ComponentsModels, XML
Labelsios, qe-manualtest
ReporterAfranio Martins
AssigneeFeon Sua Xin Miao
Created2013-12-24T14:42:05.000+0000
Updated2014-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;

//...
}

error

message = "'undefined' is not an object (evaluating '$.__views.__alloyId211.addEventListener')";

Comments

  1. Afranio Martins 2014-01-08

    A solution that works, but do not know if it is correct

    {color:red} File Alloy/commands/compile/parsers/Ti.UI.TextField.js
       
       *After*
       
    // Update the parsing state return { parent: {}, styles: state.styles, code: code };
       
       *Before*
       
       
    // Update the parsing state nodeState.styles = state.styles; nodeState.code = code; return nodeState; ``` :D
  2. Tim Poulsen 2014-05-19

    Fix for one is probably going to solve the other
  3. Feon Sua Xin Miao 2014-05-28

    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:
        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;
       
    3. The event listener is attached to the right object *__alloyId6.*
  4. Tim Poulsen 2014-05-30

    PR tested and merged
  5. Federico Casali 2014-08-22

    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 object is used, which is iOS only. Removing it , it runs fine also on Android. Reopening. TiSDK 3.4.0.v20140820125714 Appcelerator Studio 3.4.0.201408201526 CLI 3.4.0-dev Alloy 1.5.0-dev Xcode6-beta5
  6. Feon Sua Xin Miao 2014-08-26

    Master PR: https://github.com/appcelerator/alloy/pull/525 1_5_X PR: https://github.com/appcelerator/alloy/pull/526 Updated test app.
  7. Feon Sua Xin Miao 2014-08-26

    [~skypanther] would you review & merge those PRs?
  8. Tim Poulsen 2014-08-26

    I've merged the PR against master. However the PR on 1_5_X includes extraneous changes. It will need to be resubmitted.
  9. Feon Sua Xin Miao 2014-08-26

    [~skypanther] Here's the new PR. New PR for 1_5_X: https://github.com/appcelerator/alloy/pull/529
  10. Tim Poulsen 2014-08-26

    Both PRs merged
  11. Ewan Harris 2014-08-27

    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 has been removed and the app.js file in styles has been replaced by app.tss. Closing ticket.

JSON Source