i want to place a spinner on my side wich needs a javascript to run.
This javascript call is right before the body ends <script src="../plugins/jquery-spinner/js/jquery.spinner.js"></script>
The Spinner works fine if i place it hardcoded in the HTML file,
but if i use setHTML with a websocket to place the exact same code into a div, the spinner doesnt work anymore.
Since you have to declare this statically in you B4J code (via a something like: Dim content As JQueryElement), why don't you just also put it statically in you HTML and use the display property to show/hide the element as needed?
B4X:
'To hide the div with id content
content.SetProp("display", "none")
'To show the div
content.SetProp("display", "block")
i have declare it.
The content needs to be dynamic because its an appstore and will build according apps in a online Database.
So its not possible to hardcode each element.
But since i need to catch every button click inside each "App"-Element I need to do it by the whole content click event and select the click by the target.
You can create a callback via ws.Eval and JavaScript. For example, an elements click event can be set via
B4X:
Dim elementID As String = "content"
Dim clickJS As String = $" $("#${elementID}").on("click",function(){
b4j_raiseEvent('${elementID}_click', {'callerID' : '${elementID}'});
});"$
ws.Eval(clickJS, Null)
then
B4X:
Sub content_click (Params As Map)
Log(Params)
End Sub
should log an callerID map entry.
Notes:
1) Untested code
2) You've placed an element with ID "content" via setHTML
3) The HTML element with ID "content" needs to have a click event for this to work