Titanium JIRA Archive
Appcelerator Community (AC)

[AC-398] Error Alloy Data Binding Annotations

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionCannot Reproduce
Resolution Date2015-11-11T22:55:30.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy
Labelsios, iphone
ReporterFrank Eijking
AssigneeShak Hossain
Created2015-03-19T07:29:50.000+0000
Updated2015-11-11T22:55:30.000+0000

Description

I try to use annotations as a collection inside a ti.map module Modules.Map.View. Documentation says this is possible as of Alloy 1.4: [Alloy_Data_Binding](http://docs.appcelerator.com/titanium/3.0/#!/guide/Alloy_Data_Binding) Please consider the following in my view xml: {noformat} {noformat} In my controller I do a {noformat} Alloy.Collections.pins.fetch(); {noformat} Everything works fine for the above TableView. However for both above $.mapView's which contain the same dataCollection attribute as the TableView, I get the following error: *[ERROR] message = "null is not an object (evaluating '$model.__transform')";* Which according to Tony Lukasavage comment in the following post [undefined-is-not-an-object-evaluating-modeltransform](https://developer.appcelerator.com/question/155544/undefined-is-not-an-object-evaluating-modeltransform) means: "...you're attempting to use data binding notation on elements that are not inside an element with a dataCollection..." I am using Ti SDK 3.5.1.GA and Alloy 1.5.1, testing on iOS Simulator 8.2 Does anybody succesfully used Annotations for a dataCollection as of Alloy 1.4+?

Comments

  1. Frank Eijking 2015-03-19

    Also tested with Alloy 1.7.0-dev and 1.4.0, same issue.
  2. Papia Chowdhury 2015-09-02

    Hello, This issue could not be reproduced. Following test case shows Alloy data binding works properly with ti.map module. *Testing Environment:* Appcelerator Studio, build: 4.2.0.201508141038 Titanium SDK: 4.1.0 GA Alloy version : 1.7.6 iOS simulator: iphone 5s(v8.1) OS X version: 10.9.5 *Steps to reproduce:* 1. Create an alloy project 2. Add ti.map module 2. Copy following test cases in respective files. 2. Run the app. Observe that data binding annotation is working perfectly with the ti.map module. *Test Case* index.xml
       <Alloy>
       	<Collection src="pins"/>
       	<Window >
       		<!--
       		<View id="map" module="ti.map" dataCollection="pins">
       		<Annotation latitude="37.39" longitude="-122.051" title="XML Annotation" />
       		</View>
       		-->
       
       		<Module module="ti.map" method="createView" id="map" dataCollection="pins">
       			<Annotation latitude="37.39" longitude="-122.051" title="XML Annotation" />
       		</Module>
       
       	</Window>
       </Alloy>
       
    index.js
       if (!Ti.App.Properties.hasProperty('seeded')) {
       	var pins = [
       		{ title: "Appcelerator", latitude: 37.3892876, longitude: -122.0502364},
       		{ title: "Zone 1", latitude: 37.386697, longitude: -122.052028},
       		{ title: "Someplace nearby", latitude: 37.3880608, longitude: -122.0559039}
       	];
       	for(var i=0,j=pins.length;i<j;i++) {
       		Alloy.createModel('pins', {
       			title: pins[i].title,
       			latitude: pins[i].latitude,
       			longitude: pins[i].longitude
       		}).save();
       	}
       	Ti.App.Properties.setString('seeded', 'yuppers');
       }
       
       Alloy.Collections.pins.fetch();
       
       function doTransform(model) {
       	var transform = model.toJSON();
       	transform.title = '[' + transform.title + ']';
       	return transform;
       }
       
       function doFilter(collection) {
           return collection.where({title:'Appcelerator'});
       }
       
       
       $.index.open();
       
    pins.js
       exports.definition = {
       	config: {
       		"columns" : {
       			"title" : "text",
       			"latitude": "real",
       			"longitude": "real"
       		},
       		adapter: {
       			type: "sql",
       			collection_name: "pins"
       		}
       	},
       	extendModel: function(Model) {
       		_.extend(Model.prototype, {
       			// extended functions and properties go here
       		});
       
       		return Model;
       	},
       	extendCollection : function(Collection) {
       		_.extend(Collection.prototype, {
       
       			// For Backbone v1.1.2, uncomment this to override the fetch method
       			/*
       			fetch: function(options) {
       				options = options ? _.clone(options) : {};
       				options.reset = true;
       				return Backbone.Collection.prototype.fetch.call(this, options);
       			},
       			*/
       		});
       		return Collection;
       	}
       };
       
       
    index.tss
       '#index': {
       	backgroundColor: '#fff',
       	fullscreen: false,
       	exitOnClose: true
       }
       "#map": {
         userLocation: false,
         animate: true,
       	region: { latitude: 37.3892876, latitudeDelta: 0.015, longitude: -122.0502364, longitudeDelta: 0.015 }
       }
       
    Thanks

JSON Source