Bug? JQueryElement setProp not working with 'data-' attributes

alwaysbusy

Expert
Licensed User
Longtime User
There seems to be a problem with jQuery when using setProp() and attributes starting with 'data-' e.g. 'data-position'. I haven't been able to test it but I suspect the behaviour will be the same doing it in pure B4J.

This is used in one of my libraries (java):
B4X:
JQueryElement j = page.ws.GetElementById(ID.toLowerCase());
j.SetProp("data-position", ToolTipPosition);

Behaviour:
The property is not set


I solved it now by creating a function like this:

Java library
B4X:
public static void SetProperty(ABMPage page, String ID, String name, String value) {
     anywheresoftware.b4a.objects.collections.List Params = new anywheresoftware.b4a.objects.collections.List();
     Params.Initialize();
     Params.Add(ID);
     Params.Add(name);
     Params.Add(value);
     page.ws.RunFunction("SetProperty", Params);
   }

HTML
B4X:
function SetProperty(id, name, value) {
     $('#' + id).attr(name, value);
}
 
Last edited:
Top