PDA

View Full Version : Custom handling for nestedList itemtap



reynardmh
10 Jun 2011, 7:03 AM
Hi,
I'm trying to implement a NestedList so that when a non-leaf item is tapped, it does not switch the card (but implement custom handling), and when the selected non-leaf item is tapped again, that's when it will switch the card to the sublist.
I found that I can return false on beforecardswitch to prevent it, but I don't have information about which item was tapped on beforecardswitch(nestedList, oldCard, newCard, index). This information is passed on itemtap, but the problem is that itemtap is fired after beforecardswitch. So I cannot make decision on beforecardswitch whether to return false or true.
Doesn't it make more sense to fire beforecardswitch after itemtap? Or is there a good reason why the event firing is implemented in the current order?

Current order are:
beforecardswitch
itemtap
cardswitch

I would expect it to be:
itemtap
beforecardswitch
cardswitch

Anyway with the way it works now, is there a way to accomplish what I want?

Thanks,
- reynard

aondevuser1
14 Jun 2011, 2:21 PM
I call this function on cardswitch, not sure if this helps.

You might try to suspendEvents and resumeEvents too?


updateLeafs: function(list){
var ai = this.getActiveItem().store.data.items;
for(var i=0; i<ai.length; i++){
if( ai[i].data.leaf ){
console.log(ai[i].data.text + " is a leaf");
}
}
}

reynardmh
14 Jun 2011, 2:44 PM
Hi, thanks for the response!
The problem is that cardswitch is triggered after the cardswitch happens, so it's too late to suspend events.