B4J Question Get html onClick to work

TomDuncan

Active Member
Licensed User
Longtime User
Hi All

I have this code in my index.html

B4X:
<div id="maindiv">
    .. lots of stuff
    
    . then this button to show a modal (using bootstrap 3)
    <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Small Modal</button>
    
    .. then modal here
</div>

If I run this with a websocket program all is fine.
The modal open etc.

However if I place ..

B4X:
Sub maindiv_click (Params As Map)
    'find the target element
    If Params.IsInitialized Then
        Dim target As String = Params.Get("target")
        Log(target)
    End If
End Sub

in the Websocket area.
I do get which button has been pressed but the action is not been picked up in the html.

My idea is how can I send the OnClick event from the server to initiate the onClick.
Thanks
Tom
 

TomDuncan

Active Member
Licensed User
Longtime User
I tested this out and got an endless loop of the button being clicked.. :(

B4X:
        Dim button As JQueryElement = ws.GetElementById("edit_11")
        button.RunMethod("trigger", Array("click"))
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Dim button As JQueryElement = ws.GetElementById("edit_11")
Based on the html code above there is no object with this ID. Did you define a ID with this button?
 
Upvote 0
Top