Quantcast
Viewing all articles
Browse latest Browse all 8068

'undefined' is not an object (evaluating '$model.__transform')

I try to bind a details view from a TableRowView.

It's ok for complete the TableView but it's always blocking with the "clic and view details" :

> 'undefined' is not an object (evaluating '$model.__transform') at details.js (line 22).

index.xml

<TableView id="spellTable" dataCollection="spell">
      <Require src="row"/>
    </TableView>
row.xml
<Alloy>
  <TableViewRow id="rowView" model="{alloy_id}" onClick="openDetails">
    <Label id="name" text="{name}"/>
  </TableViewRow>
</Alloy>
details.xml
<Alloy>
    <Model src="Spell" />
    <Window id="detailsWin" title="Details"  model="{alloy_id}" class="container"  >
        <Label id="name" text="{name}"/>
        <Button class="button" onClick="closeWindow">back</Button>
    </Window>
</Alloy>
row.js
var spells = Alloy.Collections.spell;
 
function openDetails(e) {
    if (e.rowData){
        var detailController = Alloy.createController('details', {
            data : spells.get(e.row.model)
        });
        detailController.getView().open();
    }
  }
Model : spell.js
exports.definition = {
    config: {
        "columns": {
             "id" : "integer",
             "level": "integer",
             "name": "text", 
             "porte": "text", 
             "elements":"text", 
             "duree": "text",
             "incantation":"text", 
             "zone":"text", 
             "Sauvegarde":"text",
            "description":"text"
        },
        "adapter": {
            "type": "sql",
            "collection_name": "spell"
        }
    },
 
    extendModel : function(Model) {
        _.extend(Model.prototype, {
            validate : function(attrs) {
                for (var key in attrs) {
                    var value = attrs[key];
                    if (value) {
                        if (key === "level" || key === "name" || key === "description") {
                            if (value.length <= 0) {
                                return 'Error: No '+key+'!';
                            }
                        }
                    }
                }
            }
        });
 
        return Model;
    },
 
    extendCollection : function(Collection) {
        _.extend(Collection.prototype, {
            comparator: function(spell) {
                return spell.get('level');
            }
        });
 
        return Collection;
    }   
};
I found a lot of system but none work... I feel this is the basis and I'm already blocked. Need help :)

Viewing all articles
Browse latest Browse all 8068

Trending Articles