开发者

Sencha Touch MVC: How do I access data in a view?

New to Sencha Touch, floundering in the dark. In my controller开发者_JAVA百科, I define a a variable inside an action thus:

this.map = this.render({
    xtype: 'contact-map',
    data: this.person.data,
    listeners: {
        deactivate: function(map) {
            map.destroy();
        }
    }
});

My question is, how do I access the data element (this.person.data) from the view 'contact-map'? I know how to via a template tpl element like <p>{foo}</p>, but how would I do so in code?


data becomes a property on the view object you create.

So in your initComponent method you can reference it using the this pointer, i.e. this.data.

Event handlers for the view usually pass the view in as the first argument to the callback so you'd access it with that. In your deactivate handler you'd use map.data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜