Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating Child Panels in Sencha Touch MVC App
    primarykey
    data
    text
    <p>Developing a Sencha Touch MVC app that pulls data from json store (thats set up to a DB pulling out content from a Wordpress Blog). </p> <p>Everything works up until my "detail" panel. Instead of it listening to the TPL, its just dumping some data. The data looks similar to my blog post, but is filled with other code and doesn't make much sense. </p> <p>Here is a lean version of my list: </p> <pre><code> myApp.views.PostListView = Ext.extend(Ext.Panel, { postStore: Ext.emptyFn, postList: Ext.emptyFn, id:'postlistview', layout: 'card', initComponent: function () { /* this.newButton = new Ext.Button({ text: 'New', ui: 'action', handler: this.onNewNote, scope: this });*/ this.topToolbar = new Ext.Toolbar({ title: 'All Posts', /* items: [ { xtype: 'spacer' }, this.newButton ],*/ }); this.dockedItems = [ this.topToolbar ]; this.postList = new Ext.List({ store: myApp.stores.postStore, grouped: true, emptyText: '&lt;div style="margin:5px;"&gt;No notes cached.&lt;/div&gt;', onItemDisclosure: true, itemTpl: '&lt;div class="list-item-title"&gt;{title}&lt;/div&gt;' + '&lt;div class="list-item-narrative"&gt;&lt;small&gt;{body}&lt;/small&gt;&lt;/div&gt;', }); this.postList.on('disclose', function (record) { this.onViewPost(record); }, this), this.items = [this.postList]; myApp.views.PostListView.superclass.initComponent.call(this); }, onViewPost: function (record) { Ext.dispatch({ controller: myApp.controllers.masterController, action: 'viewpost', post: record }); }, }); </code></pre> <p>And here is the "detail" view that is called on disclosure:</p> <pre><code>myApp.views.PostSingleView = Ext.extend(Ext.Panel, { title:'Single Post', id:'postsingleview', layout:'card', style:'background:grey;', initComponent: function () { this.new1Button = new Ext.Button({ text: 'Back', ui: 'back', handler: this.onViewList, scope: this, dock:"left" }); this.top1Toolbar = new Ext.Toolbar({ items: [ this.new1Button ], title: 'Single Posts', }); this.postSinglePanel = new Ext.Panel({ layout:'fit', flex:1, scroll: 'vertical', style:'padding:10px;background:yellow;', itemTpl: '&lt;tpl for="."&gt;' + '&lt;div class="list-item-narrative"&gt;{body}&lt;/div&gt;' + '&lt;/tpl&gt;', }); this.dockedItems = [ this.top1Toolbar, this.postSinglePanel ]; myApp.views.PostSingleView.superclass.initComponent.call(this); }, onViewList: function () { Ext.dispatch({ controller: myApp.controllers.masterController, action: 'viewlist', }); }, }); </code></pre> <p>And here is the controller that its talking to:</p> <pre><code> Ext.regController('masterController', { 'index': function (options) { if (!myApp.views.mainView) { myApp.views.mainView = new myApp.views.MainView(); } myApp.views.mainView.setActiveItem( myApp.views.postView ); }, 'viewpost': function (options) { myApp.views.postSingleView.postSinglePanel.update(options.post); myApp.views.postView.setActiveItem( myApp.views.postSingleView, { type: 'slide', direction: 'left' } ); }, }); myApp.controllers.masterController = Ext.ControllerManager.get('masterController'); </code></pre> <p>When the data comes out, it looks similar to this:</p> <p><a href="http://i.imgur.com/QlQG8.png" rel="nofollow">http://i.imgur.com/QlQG8.png</a></p> <p>(the black boxes are "redacted" content, no error code there). </p> <p>In closing, I believe that the controller is "dumping" the data into "MyApp.views.PostSingleView" rather than formatting it as I request in the TPL, though I'm not sure how to fix it. Any and all help MUCH appreciated!</p> <p>UPDATE: As requested, here is the RegModel:</p> <pre><code> Ext.regModel("CategoryModel", { fields: [ {name: "id", type: "int"}, {name: "title", type: "string"}, {name: "body", type: "string"}, ], hasMany: { model: 'Post', name: 'posts' } }); </code></pre> <p>And here is a sample of the json:</p> <pre><code>{    "status":"ok",    "post":{       "id":1037,       "type":"post",       "slug":"post-title",       "url":"http:\/\/localhost:8888\/jsontest\/PostTitle\/",       "status":"publish",       "title":"Post Title",       "title_plain":"Post Title",       "content":"&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;br \/&gt;\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;\/p&gt;\n&lt;!-- PHP 5.x --&gt;",       "excerpt":"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat [...]",       "date":"2011-07-29 14:17:31",       "modified":"2011-08-30 01:33:20",       "categories":[          {             "id":87,             "slug":"the-category",             "title":"The Category",             "description":"",             "parent":17,             "post_count":5          }       ],       "tags":[       ],       "author":{          "id":2,          "slug":"tom",          "name":"tom",          "first_name":"tom",          "last_name":"",          "nickname":"",          "url":"",          "description":""       },       "comments":[       ],       "attachments":[       ],       "comment_count":0,       "comment_status":"open"    },    "previous_url":"http:\/\/localhost:8888\/jsontest\/next-post\/",    "next_url":"http:\/\/localhost:8888\/jsontest\/prev-post\/" } </code></pre>
    singulars
    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.
    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