View Full Version : [FIXED] Button loosing listener if another button is created after it.

14 Oct 2011, 12:46 PM
You will need to replace the CSS and JS file but after that if you uncomment the last script block the alert will not occur.

<!DOCTYPE html>
<script src="lib/touch/sencha-touch-all-debug-w-comments.js" type="text/javascript"></script>
<link href="lib/touch/resources/css/custom.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
name: 'test',
launch: function() {

Ext.Viewport.add(Ext.widget('button',{text: 'Hello',handler: function() { alert('tapped'); }}));
<!-- uncomment this after to see the bug.. weird -->
<!-- <script>(function() { var back = Ext.widget('button',{text: 'hi'}); })();</script> -->


Jamie Avins
15 Oct 2011, 8:26 AM
Thank you for the report.

15 Oct 2011, 9:52 AM
it really makes no sense to use 2 script tags for your logic.

if you want to create(!) a 2nd button, put it inside on you application launch method as well.

to include other classes as separate files is ok for sure.

15 Oct 2011, 11:22 AM
This was merely an example, keeping it as simple as possible. The application I am working on is much larger and took me quit a while to figure this out. So I wanted to present it in the most straight forward way as possible.

Jacky Nguyen
9 Nov 2011, 5:03 PM
You should never instantiate components outside of an 'onReady' callback of Ext.setup (or 'launch' callback of Ext.application()). Ext.setup() initializes event managers, which is needed for any event on the page to be handled properly.

9 Nov 2011, 6:44 PM
Following the Kiva and Twitter application I didn't run into this issue. Probably what I should have done in the first place…