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

ALLOY: Model Data binding problem with the first upper case in the model src

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: CLI Release 7.0.3
    • Component/s: Models
    • Labels:
      None
    • Story Points:
      1
    • Sprint:
      2018 Sprint 01 Tooling

      Description

      There is a problem with code generated for Simple Data Binding with the first upper case letter in model name.

      I have two models defined:
      app/models/book.js
      app/models/Task.js

      I expect that following XMLs will produce the same code:

      <Alloy>
      	<Model src="book"/>
      	<Label>{book.name}</Label>
      </Alloy>
      

      <Alloy>
      	<Model src="Task"/>
      	<Label>{Task.name}</Label>
      </Alloy>
      

      But in the first case it is correct:

      	Alloy.Models.instance('book');
       
      	$.__views.Book = Ti.UI.createLabel({ id: "Book" });
      	$.__views.Book && $.addTopLevelView($.__views.Book);
      	var __alloyId2 = function () {
      		Alloy['Models']['book'].__transform = _.isFunction(Alloy['Models']['book'].transform) ? Alloy['Models']['book'].transform() : Alloy['Models']['book'].toJSON();$.Book.text = Alloy['Models']['book']['__transform']['name'];
      	};Alloy['Models']['book'].on('fetch change destroy', __alloyId2);exports.destroy = function () {
      		Alloy['Models']['book'] && Alloy['Models']['book'].off('fetch change destroy', __alloyId2);
      	};
      

      and in the second case it is invalid:

      	$.__views.Task = Ti.UI.createLabel({ text: $model.__transform.Task.name, id: "Task" });
      	$.__views.Task && $.addTopLevelView($.__views.Task);
      

      and I get error $model.__transform is undefined

        Attachments

          Activity

            People

            • Assignee:
              fmiao Feon Sua Xin Miao
              Reporter:
              darknos Sergey Nosenko
            • Watchers:
              5 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 Source Code