Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to activate a specific card in Sencha Touch from a different Card using onclick
    primarykey
    data
    text
    <p>I've got a few different cards in my app, and I'm trying to activate one of my sub cards from my homepage screen.</p> <p>Here is the pertinent information.</p> <p><strong>Setup</strong></p> <pre><code>Ext.setup({ id: 'Ext-setup', onReady: function () { rpc.main.init(); } }); </code></pre> <p><strong>Main</strong></p> <pre><code>rpc.main = { init: function () { var rootPanel = new Ext.TabPanel({ id: 'rpc-rootPanel', fullscreen: true, layout: 'card', region: 'center', items: [ rpc.controllers.HomeController, rpc.controllers.VimeoController, ] }); } }; </code></pre> <p><strong>HomeController</strong></p> <pre><code>rpc.controllers.HomeController = new Ext.Panel({ id: 'rpc-controllers-homecontroller', layout: 'card', items: [rpc.views.Home.index], listeners: { activate: function () { if (rpc.stores.HomeStore.getCount() === 0) { // This store uses the rpc.templates.AboutDetails XTemplate rpc.stores.HomeStore.load(); } } } }); </code></pre> <p><strong>Home Index View</strong></p> <pre><code>rpc.views.Home.index = new Ext.DataView({ id: 'rpc-views-home-index', itemSelector: 'div.home-index', tpl: rpc.templates.AboutDetails, store: rpc.stores.HomeStore, fullscreen: true, }); </code></pre> <p><strong>Vimeo Controller</strong></p> <pre><code>rpc.controllers.VimeoController = new Ext.Panel({ id: 'rpc-controllers-VimeoController', layout: 'card', fullscreen: true, items: [rpc.views.Vimeo.index, rpc.views.Vimeo.Details] }); </code></pre> <p><strong>Vimeo Index View</strong></p> <pre><code>rpc.views.Vimeo.index = new Ext.Panel({ id: 'rpc-views-Vimeo-index', layout: 'fit', dockedItems: [{xtype: 'toolbar', title: 'Videos'}] // stuff left out to keep it clean }); </code></pre> <p><strong>The Template I'm using to try and activate the card</strong> <em>This is where you'll see the javascript call <code>javascript:goToCard();</code></em></p> <pre><code>rpc.templates.AboutDetails = new Ext.XTemplate( ' &lt;tpl for="."&gt;', ' &lt;div class="padded"&gt;', ' &lt;div class="rounded-div"&gt;', ' &lt;h1&gt;RockPointe Church&lt;/h1&gt;', ' &lt;span class="rpc-sub"&gt;One church meeting in multiple locations.&lt;/span&gt;', ' &lt;/div&gt;', ' &lt;div&gt;', ' &lt;div id="quick-nav"&gt;', ' &lt;ul&gt;', ' &lt;li&gt;&lt;span onclick="javascript:goToCard(\'rpc-controllers-VimeoController\',\'rpc-views-Vimeo-index\');"&gt;Videos&lt;/span&gt;&lt;/li&gt;', ' &lt;li&gt;&lt;span onclick="javascript:goToCard()"&gt;Events&lt;/span&gt;&lt;/li&gt;', ' &lt;li&gt;&lt;span onclick="javascript:goToCard()"&gt;Sites&lt;/span&gt;&lt;/li&gt;', ' &lt;/ul&gt;', ' &lt;br clear="left"&gt;', ' &lt;/div&gt;', ' &lt;/tpl&gt;' </code></pre> <p><strong>And finally, the <code>goToCard();</code> method</strong></p> <pre><code>function goToCard(panelId, cardId) { Ext.getCmp(panelId).setActiveItem(cardId); } </code></pre> <p>The problem is simple... nothing happens when I click on the </p> <pre><code>&lt;span onclick="javascript:goToCard(\'rpc-controllers-VimeoController\',\'rpc-views-Vimeo-index\');"&gt;Videos&lt;/span&gt; </code></pre> <p>If I run the code directly in my console </p> <pre><code>Ext.getCmp('rpc-controllers-VimeoController').setActiveItem('rpc-views-Vimeo-index'); </code></pre> <p>I get the following output.</p> <blockquote> <p>subclass<br> additionalCls: Array[0]<br> autoRender: true<br> body: El.Ext.Element.Ext.extend.constructor<br> cardSwitchAnimation: "slide"<br> componentCls: "x-panel"<br> componentLayout: subclass<br> container: El.Ext.Element.Ext.extend.constructor<br> dockedItems: Ext.util.MixedCollection<br> el: El.Ext.Element.Ext.extend.constructor<br> events: Object<br> fullscreen: true<br> getTargetEl: function () {<br> height: 306<br> hidden: true<br> hiddenOwnerCt: false<br> iconCls: "tv"<br> id: "rpc-controllers-VimeoController"<br> initialConfig: Object<br> items: Ext.util.MixedCollection<br> layout: subclass<br> layoutOnShow: Ext.util.MixedCollection<br> monitorOrientation: true<br> mons: Array[0]<br> needsLayout: false<br> originalGetTargetEl: function () {<br> ownerCt: subclass<br> renderData: Object<br> renderSelectors: Object<br> renderTo: null<br> rendered: true<br> scroll: "vertical"<br> scrollEl: El.Ext.Element.Ext.extend.constructor<br> scroller: Ext.util.Scroller.Ext.extend.constructor<br> tab: subclass<br> title: "Video"<br> width: 798<br> <strong>proto</strong>: F </p> </blockquote> <p>But nothing actually happens :-(<br> Basically, I don't get an error, nor does the appropriate view load.</p> <p>I also tried<br> <code>Ext.getCmp('rpc-controllers-VimeoController').layout.setActiveItem('rpc-views-Vimeo-index');</code></p> <p>But the response was even less...</p> <blockquote> <p>False</p> </blockquote> <p>If I just run<br> <code>Ext.getCmp('rpc-controllers-VimeoController');</code><br> I can see the <code>'rpc-views-Vimeo-index'</code> ID within the items array.</p>
    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