Titanium JIRA Archive
Alloy (ALOY)

[ALOY-645] onClick="nested.object.here" throws errors in Alloy

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2014-01-21T19:33:22.000+0000
Affected Version/sn/a
Fix Version/s2014 Sprint 02
Componentsn/a
LabelsAlloy
ReporterDaniel Sefton
AssigneeTony Lukasavage
Created2013-04-28T00:38:36.000+0000
Updated2014-01-28T23:55:22.000+0000

Description

As discussed here: http://developer.appcelerator.com/question/151438/coffeescript-with... using <... onClick="nested.object"> throws errors because the generated code includes $.nested.object ? ... and this is defined above the user's controller! you should use something like like this: _.get('nested.object') which is available https://npmjs.org/package/underscore.nested

Comments

  1. Tony Lukasavage 2014-01-21

    The following code works just fine, and works exactly the same if you prefix the event handler name and function declaration with exports as well:

    index.xml

       <Alloy>
       	<Window class="container">
       		<Label id="label" onClick="nested.doClick">Hello, World</Label>
       	</Window>
       </Alloy>
       

    index.js

       var nested = {
           doClick: function(e) {
               alert($.label.text);
           }
       };
       
       $.index.open();
       
    There are no inherent errors with using namespaces as event handlers from your views. Alloy does not officially support coffeescript and the code generation and handling won't be changed to support it at the potential expense of stability of existing code written in pure JS.

JSON Source