B4J Question [BANano] Using html template

Luk

Member
Licensed User
Longtime User
Hi,

Is it possible to specify a html template and add the generated javascript to this html file ?
e.g.
B4X:
BANano.HTML_TEMPLATE = "my template.html"

Or should I use the following method. (javascript is adding the elements)
B4X:
Dim j As BANanoElement
    j = BANano.GetElement("body")  
    j.Append($"
    <div id='content'>      
            <button id="defaultButton">Default</button>
            <button id="primaryButton">Primary</button>
            <button id="infoButton">Info</button>
            <button id="successButton">Success</button>
            <button id="warningButton">Warning</button>
            <button id="dangerButton">Danger</button>
            <button id="inverseButton">Inverse</button>
            <button id="linkButton">Link</button>
        </div>
    "$)

Thanks !
 

Kiffi

Well-Known Member
Licensed User
Longtime User
You could load templates via CallAjax():

B4X:
Sub ...

  BANano.CallAjax("./assets/MyTemplate.html", "GET", "text", Null, "MyTemplate", False, CreateMap())

End Sub

Sub BANano_CallAjaxResult(Success As Boolean, UniqueID As String, Result As String)
 
  If Success Then
    Select UniqueID
      Case "MyTemplate"
        BANano.GetElement("body").Append(Result)
    End Select
  End If
 
End Sub

Greetings ... Peter
 
Upvote 0
Top