Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Unable to bind model to table tableView in alloy.

$
0
0

I'm using napp.alloy.adapter.restapi to pull a list of clinics from parse.com. The api calls using the lib works fine. In success call back for the fetch i'm able to console.log the attributes. But for some reason i'm not getting things wired up correct to populate the tableView. Thanks in advance!

clinic.js - controller

var clinic = Alloy.createCollection("clinic");
 
clinic.fetch({
    success : function() {
        Ti.API.info(JSON.stringify(clinic.models));
        _.each(clinic.models, function(element, index, list) {
            Ti.API.info(JSON.stringify(element.attributes['name']));
        });
    },
    error : function() {
        Ti.API.error("hmm - this is not good!");
    }
});
clinic.js - model
exports.definition = {
    config: {
        "columns": {
            "name": "String",
            "phone": "String",
            "fax": "String"
        },
        "URL": "https://api.parse.com/1/classes/clinic",
        //"debug": 1, 
        "adapter": {
            "type": "restapi",
            "collection_name": "clinic",
            "idAttribute": "objectId"
        },
        "headers": { // your custom headers
            "X-Parse-Application-Id": "...",
            "X-Parse-REST-API-Key": "..."
        },
        "parentNode": "results"
    },
 
    extendModel: function(Model) {
        _.extend(Model.prototype, {});
        return Model;
    },
    extendCollection: function(Collection) {
        _.extend(Collection.prototype, {});
        return Collection;
    }
};
clinic.xml
<Alloy>
    <Collection src="clinic" />
    <Window id="winContent">
        <TableView dataCollection="clinic">
            <TableViewRow title="{name}"  />
        </TableView>
    </Window>
</Alloy>

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>