Uploaded image for project: 'Alloy'
  1. Alloy
  2. ALOY-1478

Data binding fails when binding string or model attribute name has dash, space or quote

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: alloy 1.7.35, alloy 1.8.0
    • Fix Version/s: Release 5.4.0, alloy 1.9.0
    • Component/s: Models, XML
    • Labels:
      None
    • Story Points:
      5
    • Sprint:
      2016 Sprint 16 Tooling

      Description

      Alloy data binding can't handle complex bindings strings or model attributes names that contain a dash, space or quotes.

      This is in part because of the way it renders the compiled _.template() code, but also because of limitations in _.template() itself:
      http://stackoverflow.com/a/15956433/4626813

      <Alloy>
      	<Model src="mymodel" />
      	<Collection src="mymodel" />
      	<Window>
      		<ScrollView layout="vertical">
       
      			<!-- ALL OK -->
      			<Label top="30" text="{mymodel.a}" />
       
      			<!-- COMPILE ERROR -->
      			<!-- <Label text="{mymodel.a'b}" /> -->
      			<!-- <Label text="he's {mymodel.a}" /> -->
       
      			<!-- RUN-TIME ERROR -->
      			<!-- <Label text="{mymodel.a-b}" /> -->
      			<!-- <Label text="{mymodel[a-b]}" /> -->
      			<!-- <Label text="{mymodel.a b}" /> -->
      			<!-- <Label text='{mymodel.a"b}' /> -->
       
      			<ListView>
      				<ListSection dataCollection="mymodel">
       
      					<!-- ALL OK -->
      					<ListItem title="{a}" />
       
      					<!-- COMPILE ERROR -->
      					<!-- <ListItem title="{a'b}" /> -->
       
      					<!-- RUN-TIME ERROR -->
      					<!-- <ListItem title="{a-b}" /> -->
      					<!-- <ListItem title="{[a-b]}" /> -->
      					<!-- <ListItem title="{a b}" /> -->
      					<!-- <ListItem title='{a"b}' /> -->
       
      				</ListSection>
      			</ListView>
      		</ScrollView>
      	</Window>
      </Alloy>
      

      index.js

      var test = {
        a: 'a',
        'a-b': 'a-b',
        'a b': 'a b',
        'a"b': 'a"b',
        "a'b": "a'b"
      };
       
      Alloy.Models.mymodel.set(test);
      Alloy.Collections.mymodel.reset([test]);
       
      $.index.open();
      

      mymodel.js

      exports.definition = {};
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                fmiao Feon Sua Xin Miao
                Reporter:
                fokkezb Fokke Zandbergen
                Reviewer:
                Feon Sua Xin Miao
              • Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration