Note that there are some explanatory texts on larger screens.

plurals
  1. POForm + nested list not showing after submit
    primarykey
    data
    text
    <p>I'm just learning sencha touch 2, MVC. I would to make a simple form that get a value, pass to a PHP file (for an API call to a web-service), move to a Nested List and show results. But, my app doesn't show nothing after submit... Value is captured correctly (I see it in console log). Please someone could me help?</p> <p>Consider for testing that for now I don't pass value, and my API call calls directly with a hard-coded value. In future I'll work to pass form value...</p> <p>Thank you in advance!</p> <p>This is "app.js"</p> <pre><code>Ext.application({ name: 'Appre', icon: 'resources/icons/icon.png', phoneStartupScreen: 'resources/images/phone_startup.png', //tabletStartupScreen: 'tablet_startup.png', glossOnIcon: false, //profiles: ['Phone', 'Tablet'], views : ['Viewport','SearchCap','ElencoRistoranti'], models: ['ElencoRistoranti'], stores: ['RistorantiCap'], controllers: ['SearchCap'], viewport: { layout: { type: 'card', animation: { type: 'slide', direction: 'left', duration: 300 } } }, launch: function() { Ext.create('Appre.view.Viewport') } // launch: function() { }) // Ext.application </code></pre> <p>This is form "search cap"</p> <pre><code>Ext.define('Appre.view.SearchCap', { extend: 'Ext.form.Panel', xtype: 'appre-searchCap', config: { items: [{ xtype: 'fieldset', layout: 'vbox', items: [{ xtype: 'textfield', name: 'cap', placeHolder: 'Cap' }, { xtype: 'button', text: 'Cerca', action :'searchCap', id:'btnSubmitLogin' }] // items }] // items }, // config initialize: function() { this.callParent(arguments); console.log('loginform:initialize'); } }); </code></pre> <p>This is controller</p> <pre><code>Ext.define('Appre.controller.SearchCap', { extend : "Ext.app.Controller", config : { refs : { btnSubmitLogin: 'button[action=searchCap]', form : 'appre-searchCap' }, control : { btnSubmitLogin : { tap : "onSubmitLogin" } } }, onSubmitLogin : function() { console.log("onSubmitLogin"); var values = this.getForm().getValues(); console.log(values); var $this=this; Ext.Ajax.request({ url: 'cerca-ristoranti-cap.php', method: 'POST', params: { values: Ext.encode({form_fields: values}) }, success: function(response, opts) { var obj = Ext.decode(response.responseText); //Ext.Msg.alert('Contact Complete!', obj.responseText); $this.resetForm(); Ext.Viewport.add(Ext.create('Appre.view.ElencoRistoranti')); Ext.Viewport.setActiveItem(Ext.create('Appre.view.ElencoRistoranti')); }, failure: function(response, opts) { console.log('server-side failure with status code ' + response.status); } }); }, resetForm: function() { this.getForm().reset(); }, launch : function() { this.callParent(); console.log("LoginForm launch"); }, init : function() { this.callParent(); console.log("LoginForm init"); } }); </code></pre> <p>And this is Nested List</p> <pre><code>Ext.define('Appre.view.ElencoRistoranti', { extend: 'Ext.Panel', xtype: 'appre-elencoristoranti', config: { xtype: 'nestedlist', title: 'Cap', displayField: 'name', store: { type: 'tree', fields: [ 'id_restaurant', 'name', {name: 'leaf', defaultValue: true} ], root: { leaf: false }, proxy: { type: 'ajax', url: 'cerca-ristoranti-cap.php', reader: { type: 'json', rootProperty: 'restaurants' } //reader } // proxy }, detailCard: { xtype: 'panel', scrollable: true, styleHtmlContent: true }, listeners: { itemtap: function(nestedList, list, index, element, post) { this.getDetailCard().setHtml(post.get('name')); } } } // config }); </code></pre> <p>cerca-ristoranti-cap.php it's a simple function that returns an array like this:</p> <pre><code>{ "restaurants":[{ "id_restaurant":"40", "name":"La Saliera", "zip":"00128", "lat":"41.7900229", "lgt":"12.4513128" }, { "id_restaurant":"64", "name":"Osteria del Borgo", "zip":"00128", "lat":"41.7887363", "lgt":"12.5149867" }] </code></pre> <p>} </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload