viezel / napp.alloy.adapter.restapi

RestAPI Sync Adapter for Titanium Alloy Framework
197 stars 102 forks source link

Output result to xml #71

Open sobytes opened 9 years ago

sobytes commented 9 years ago

Hi All,

How do i export the result to the view?

var api = Alloy.createCollection("api");
    api.fetch({
        url: "http://jsonplaceholder.typicode.com/posts",
        // uncomment and add data to post
        //data : {},
        add: true,
        silent: true,
        processData : false,
        success : function(_model, _response) {
            Ti.API.info(_response);
        },
        error : function(_model, _response) {
            Ti.API.info('Events Fetch Error');
            Ti.API.info(_response);
        }
    });

And my view

<Alloy>
    <Collection src="api"/>
    <Window class="container" onOpen="windowOpen">
        <TableView id="table" dataCollection="api">
            <TableViewRow>
                <Label text="{title}"></Label>
                <Label text="{body}"></Label>
            </TableViewRow>
        </TableView>
    </Window>
</Alloy> 

Can you tell me where i am going wrong?

sobytes commented 9 years ago

Ok sussed it i have put together a little sample project for newbie like me to save some time.

https://bitbucket.org/SoBytes/napp.alloy.adapter.restapi-alloy-example/src