Note that there are some explanatory texts on larger screens.

plurals
  1. POSencha Touch 2 : A simple handler for HTML Button displayed insided panel is giving undefined error
    text
    copied!<p>I have a pretty simple html. This html is displayed inside Sencha Panel using panel.setHtml method. LayOut of the sample HTML is as below.</p> <p><em><strong>HTML File</em></strong></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script&gt; function copyText() { alert('It is clicked'); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; Field1: &lt;input type="text" id="field1" value="Hello World!"&gt;&lt;br&gt; Field2: &lt;input type="text" id="field2"&gt; &lt;br&gt;&lt;br&gt; &lt;button onclick="copyText()"&gt;Copy Text&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Below code sets html inside the panel.The above mentioned html is truncated into one line and is set inside the panel as below.</p> <pre><code>var res = '&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;script&gt;function copyText(){}&lt;/script&gt;&lt;/head&gt;&lt;body&gt;Field1: &lt;input type="text" id="field1" value="Hello World!"&gt;&lt;br&gt;Field2: &lt;input type="text" id="field2"&gt;&lt;br&gt;&lt;br&gt;&lt;button onclick="copyText()"&gt;Copy Text&lt;/button&gt;&lt;p&gt;A function is triggered when the button is clicked. The function copies the text from Field1 into Field2.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;'; Ext.getCmp('dummyPanel').setHtml(res); </code></pre> <p><strong>ISSUE :</strong></p> <p><strong>When the Button is clicked, I am getting 'Uncaught ReferenceError: copyText is not defined' Error.</strong></p> <p>Any ideas of what wrong I am doing here? Cant we set the complete html with the inside the sencha panel.</p> <p>The running code is at <strong><a href="http://www.senchafiddle.com/#5LdC5" rel="nofollow">http://www.senchafiddle.com/#5LdC5</a></strong></p> <p>Please help.</p> <p>Thank you, Gendaful</p>
 

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