Bug? Problem in b4j_ws.js

billyrudi

Active Member
Licensed User
Longtime User
Hi,
the version of b4j_ws.js 0.91
have this instrunction that my cause problems in event return target parameter:

B4X:
function b4j_addEvent(selector, event, eventName, preventDefault) {
    var obj = $(selector);
    if (obj.length > 0) {
        obj.on(event, function (e) {
            if (preventDefault) {
                e.preventDefault();
                e.stopPropagation();
            }
            b4j_raiseEvent(eventName, {which: e.which, target: e.target.id, pageX: e.pageX, pageY: e.pageY, metaKey: e.metaKey});
        });
    }
}

when event is declared with


B4X:
Sub SetEventObjectName(EventObjectName As String, EventName As String, PreventDefault As Boolean)
    EventObjectName = EventObjectName.ToLowerCase
    EventName = EventName.ToLowerCase
    RemoveEvent(EventName)
    mWS.RunFunction("b4j_addEvent", Array As Object("#" & mID, EventName, EventObjectName & "_" & EventName, PreventDefault))
End Sub

replacing with the oldest version

B4X:
function b4j_addEvent(selector, event, eventName, preventDefault) {
    var obj = $(selector);
    if (obj.length > 0) {
        obj.on(event, function (e) {
            if (preventDefault) {
                e.preventDefault();
                e.stopPropagation();
            }
            if (e.target.id) {
                b4j_raiseEvent(eventName, {which: e.which, target: e.target.id, pageX: e.pageX, pageY: e.pageY, metaKey: e.metaKey});
            } else {
                b4j_raiseEvent(eventName, {which: e.which, target: selector, pageX: e.pageX, pageY: e.pageY, metaKey: e.metaKey});
            }
        });
    }
}

event is fired correctly.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…