PDA

View Full Version : [CLOSED] "selectionchange" fires two times



johnnywengluu
4 Nov 2011, 9:49 AM
I am listening on the "selectionchange" event on a list.

Whenever I tap on a new item, my "selectionchange" event handler is fired two times.

Bug?

yoh.suzuki
4 Nov 2011, 10:29 AM
It's firing one event for the deselect, and another for the select. You can use Ext.Function.createBuffered to create a buffered version of your selectionchange handler to handle the second event.

johnnywengluu
4 Nov 2011, 10:37 AM
It just seems better to have it called one time, giving me both the old selection and the new selection.

More user friendly. Maybe as a new feature.

Thoughts?

mitchellsimoens
4 Nov 2011, 11:27 AM
If you are only wanting an event to fire on select... use that event.

And the correct way to buffer an event firing is these two ways:


listeners : {
selectionchange : {
buffer : 100, //number in milliseconds
fn : someFn
}
}

list.on('selectionchange', someFn, scope, { buffer : 100 });