Permalink
Browse files

Check all types of an entity to find one we have template for

  • Loading branch information...
1 parent e28dcad commit e1f9980f34e9971b2120723275fb36fe5627eaec @bergie committed Sep 21, 2012
Showing with 15 additions and 6 deletions.
  1. +3 −2 src/Collection.js
  2. +12 −4 src/view/CollectionView.js
View
5 src/Collection.js
@@ -57,9 +57,10 @@ VIE.prototype.Collection = Backbone.Collection.extend({
throw new Error("No model given");
}
- if (_.isString(model) && collection.isReference(model)) {
+ if (_.isString(model)) {
model = {
- '@subject': model
+ '@subject': model,
+ id: model
};
}
View
16 src/view/CollectionView.js
@@ -57,12 +57,20 @@ VIE.prototype.view.Collection = Backbone.View.extend({
}
var childType = entity.get('@type');
+ var childTypeName;
if (_.isArray(childType)) {
- childType = childType[childType.length - 1];
+ _.each(childType, function (type) {
+ if (this.canAdd(type.id)) {
+ childTypeName = type.id;
+ }
+ }, this);
+ } else {
+ if (this.canAdd(childType.id)) {
+ childTypeName = childType.id;
+ }
}
- var childTypeName = childType.id;
-
- if (!this.canAdd(childTypeName)) {
+
+ if (!childTypeName) {
return;
}

0 comments on commit e1f9980

Please sign in to comment.