Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The class system has changed quite a lot in Sencha Touch 2 compared to 1.x. It is now very similar to how ExtJS 4 is. The idea behind the changes is to make it easier to understand, quicker to develop and more dynamic.</p> <p>Some changes:</p> <ul> <li>you should no longer use <code>new HTMLPanel({})</code>. Instead, use <code>Ext.create</code>, i.e. <code>Ext.create('HTMLPanel', {})</code>.</li> <li>you should no longer use <code>Ext.extend</code> to define your custom classes. Instead, use <code>Ext.define</code> with an <code>extend</code> property.</li> <li>you do not need to use <code>HTMLPanel.superclass.constrctor.apply(this, arguments)</code> anymore to call the parent. Instead, you can use <code>this.callParent(arguments)</code></li> <li><p>you should very rarely override <code>constructor</code>. This is bad practise. Instead, you should use the <code>config</code> block:</p> <pre><code>Ext.define('HTMLPanel', { extend: 'Ext.Panel', config: { html: 'This is the html of this panel.' } }); </code></pre> <p>Please note that configurations only go within the <code>config</code> block when you define a new class using <code>Ext.define</code>. If you are creating a new instance of a class using <code>Ext.create</code>, <code>new ClassName</code> or using an object with an xtype, configurations do <em>not</em> need to be within the config object.</p></li> </ul> <p>You can find out more information about the new class system by reading <a href="http://docs.sencha.com/touch/2-0/#!/guide/class_system" rel="nofollow">this guide</a>. There is also a great guide on how to migrate from 1.x to 2.x <a href="http://docs.sencha.com/touch/2-0/#!/guide/upgrade_1_to_2" rel="nofollow">here</a>.</p> <p>So, lets make your code work.</p> <p><strong>index.html</strong> (nothing needs to change):</p> <pre><code>&lt;script type="text/javascript" src="touch/sencha-touch-debug.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="HTMLPanel.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="app.js"&gt;&lt;/script&gt; </code></pre> <p><strong>app.js</strong>:</p> <pre><code>// You should use Ext.application, not Ext.setup Ext.application({ name: 'SampleLoad', requires: ['HTMLPanel'], launch: function () { var HTMLPanel = Ext.create('HTMLPanel', { // this is now `scrollable`, not `scroll` //scroll: 'vertical', scrollable: 'vertical', url: 'sample.html' }); // Add the new HTMLPanel into the viewport so it is visible Ext.Viewport.add(HTMLPanel); } }); </code></pre> <p><strong>HTMLPanel.js</strong>:</p> <pre><code>// You do not need to save a reference to HTMLPanel when you define your class //var HTMLPanel = Ext.define('HTMLPanel', { Ext.define('HTMLPanel', { extend: 'Ext.Panel', // We are using Ext.Ajax, so we should require it requires: ['Ext.Ajax'], config: { listeners: { activate: 'onActivate' }, // Create a new configuration called `url` so we can specify the URL url: null }, onActivate: function(me, container) { Ext.Ajax.request({ // we should use the getter for our new `url` config url: this.getUrl(), method: "GET", success: function(response, request) { // We should use the setter for the HTML config for this me.setHtml(response.responseText); }, failure: function(response, request) { me.setHtml("failed -- response: " + response.responseText); } }); } }); </code></pre> <p>Hopefully this helps.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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