jeudi 15 mai 2014

How to comunicate with an API with Sencha

I'm working with sencha touch architect, but i don't know how to access a rest PHP API I just made (to edit content from a Json database). Does anyone has a clue about the steps of doing so?

Store code:

Ext.define('Leituras.store.Leituras', { extend: 'Ext.data.Store', requires: [ 'Leituras.model.Leituras', 'Ext.data.proxy.Rest', 'Ext.data.reader.Json', 'Ext.data.writer.Json' ], config: { autoLoad: true, model: 'Leituras.model.Leituras', storeId: 'Leituras', proxy: { type: 'rest', url: 'http://localhost:81/exemplos/03/projeto/dados/leituras.php', reader: { type: 'json', rootProperty: 'dados' }, writer: { type: 'json' } } }});Controller code (for delete):


var me = this, titulo = 'Apagar', mensagem = 'Deseja realmente apagar a leitura?';var popupApagar = Ext.MessageBox;Ext.apply(popupApagar, { YES: { text: 'Sim', itemId: 'sim' }});Ext.apply(popupApagar, { NO: { text: 'Não' }});Ext.apply(popupApagar, { YESNO: [Ext.MessageBox.NO, Ext.MessageBox.YES]});Ext.Msg.confirm(titulo, mensagem, function(resposta) { if(resposta == 'sim') { var navPrincipal = me.getNavPrincipal(), leituras = Ext.getStore('Leituras'), leitura = navPrincipal.getRecord(); leituras.remove(leitura); navPrincipal.pop(); }});





Aucun commentaire:

Enregistrer un commentaire