View Full Version : setActiveItem after event firing twice

29 Apr 2011, 12:09 PM
When I press the button in this app, the console output is:

index.js:20after call #1
index.js:20after call #2

Tested with sencha 1.0 and 1.1 with safari 5 and chrome 12 with same result.

I've used the after option before without issue, so I'm pretty lost as to why this is happening...

Can anyone confirm my sanity?

var n = 0;

Ext.onReady(function() {
var viewport = new Ext.Panel({
fullscreen: true
,layout: 'card'
,items: {html: 'home card'}
,dockedItems: [{
xtype: 'toolbar'
,items: [{
text: 'next'
,scope: this
,handler: function() {

viewport.setActiveItem(new Ext.Component({html: 'second card'}), {
type: 'slide'
,after: function() {
console.info('after call #%s', n);

13 Jun 2011, 10:48 AM
Is there an explanation for this, or do we have do kluge our way around it?

26 Jun 2011, 5:42 PM
I've prepared a complete code sample of this duplicate event firing taking place. Additionally I've included my (non-thread safe) work-around.

The gist is that I keep track of a fire count for the after event and ensure that my behavior only takes place during a zero cycle. Pretty simple; and you can make it component-safe at least by using a separate variable to track the state. (A boolean would suffice as well.)


I would like to know whether or not this issue is fixed in the forthcoming senchatouch release or if there is a live patch available for the library that fixes it. Chasing issues in the code is far more than tricky.