Kiffi Well-Known Member Licensed User Longtime User Dec 5, 2018 #1 Hello, i try to set the style for a BNanoElement with SetStyle() but the code taken from the documentation doesn't work for me: SetStyle (json As java.lang.Object) As void Sets the style of the target BANanoElement. example: <code> dim json as JSONGenerator json.initialize("{ background: 'green', display: 'none', 'border-radius': '5px' }") BANano.Get("#someid").SetStyle(json) </code> src\b4j\example\main.java:100: error: incompatible types: String cannot be converted to MyMap Click to expand... And it is not possible to initialize the JSONGenerator with a Map because BNano doesn't support it. Thanks in advance & Greetings ... Peter (B4J: 6.80 B1 / Json: 1.10 / BNano: 1.03)
Hello, i try to set the style for a BNanoElement with SetStyle() but the code taken from the documentation doesn't work for me: SetStyle (json As java.lang.Object) As void Sets the style of the target BANanoElement. example: <code> dim json as JSONGenerator json.initialize("{ background: 'green', display: 'none', 'border-radius': '5px' }") BANano.Get("#someid").SetStyle(json) </code> src\b4j\example\main.java:100: error: incompatible types: String cannot be converted to MyMap Click to expand... And it is not possible to initialize the JSONGenerator with a Map because BNano doesn't support it. Thanks in advance & Greetings ... Peter (B4J: 6.80 B1 / Json: 1.10 / BNano: 1.03)
alwaysbusy Expert Licensed User Longtime User Dec 5, 2018 #2 I think it is just the example that is wrong (I copied the json style from another page if I recall correct): this should work: B4X: dim json as JSONGenerator json.initialize($"{"background-color": "red", "border-radius": "5px"}"$) BANano.GetElement("#someid").SetStyle(json) As for JSONGenerator not supporting a Map, this would be a bug, as it should (with the Initialize method) Upvote 0
I think it is just the example that is wrong (I copied the json style from another page if I recall correct): this should work: B4X: dim json as JSONGenerator json.initialize($"{"background-color": "red", "border-radius": "5px"}"$) BANano.GetElement("#someid").SetStyle(json) As for JSONGenerator not supporting a Map, this would be a bug, as it should (with the Initialize method)
Kiffi Well-Known Member Licensed User Longtime User Dec 5, 2018 #3 ok, i figured it out. I have to call SetStyle() with a String: B4X: BANano.GetElement("body").Append("<div id='myDiv'></div>") Dim myDiv As BANanoElement myDiv = BANano.GetElement("#myDiv") Dim myJson As String = $"{ "width": "200px", "height": "200px", "background": "green", "border-radius": "5px" }"$ myDiv.SetStyle(myJson) Greetings ... Peter Upvote 0
ok, i figured it out. I have to call SetStyle() with a String: B4X: BANano.GetElement("body").Append("<div id='myDiv'></div>") Dim myDiv As BANanoElement myDiv = BANano.GetElement("#myDiv") Dim myJson As String = $"{ "width": "200px", "height": "200px", "background": "green", "border-radius": "5px" }"$ myDiv.SetStyle(myJson) Greetings ... Peter
alwaysbusy Expert Licensed User Longtime User Dec 5, 2018 #4 alwaysbusy said: As for JSONGenerator not supporting a Map, this would be a bug, as it should (with the Initialize method) Click to expand... I found what it is I think, it seems I'm double JSONing in case of a map. Upvote 0
alwaysbusy said: As for JSONGenerator not supporting a Map, this would be a bug, as it should (with the Initialize method) Click to expand... I found what it is I think, it seems I'm double JSONing in case of a map.