B4J Question [BANano] How to get all events linked to an element?

Mashiane

Expert
Licensed User
Longtime User
Ola

I'm trying to debug my app as its not firing any of the assigned events. How can I get a listing of all events linked to an element using BANano?

I have found this on stack-overflow..

B4X:
function getEvents(element) {
    var elemEvents = $._data(element, "events");
    var allDocEvnts = $._data(document, "events");
    for(var evntType in allDocEvnts) {
        if(allDocEvnts.hasOwnProperty(evntType)) {
            var evts = allDocEvnts[evntType];
            for(var i = 0; i < evts.length; i++) {
                if($(element).is(evts[i].selector)) {
                    if(elemEvents == null) {
                        elemEvents = {};
                    }
                    if(!elemEvents.hasOwnProperty(evntType)) {
                        elemEvents[evntType] = [];
                    }
                    elemEvents[evntType].push(evts[i]);
                }
            }
        }
    }
    return elemEvents;
}

Usage

B4X:
getEvents($('#myElemId')[0])

Not tested though... Do we have an equivalent for BANano?
 
Top