B4J Question WebApp - Handle JQueryElement click from a standard class

hatzisn

Expert
Licensed User
Longtime User
Take a look at the following code for a standard class. I initialize the class and I set the PaginationID with the correct ID (which is not 'ulist' but connect it to the ulist JQueryElement which is a general JQueryElement) from the HTML page. The class renders correctly the pagination but there is a problem with the click event. Why doesn't the ulist_click event fire? (pagination in bootstrap 5 is an unordered list with listitems).

ClassCode:
Private Sub Class_Globals
    Private ulist As JQueryElement
    Private wslocal as WebSocket
    Private parObj As Object
    Private sEv As String
    Private wslocal As WebSocket
    Private connLocal As SQL
    Private PaginationIDLocal As String
End Sub

Public Sub Initialize(Parent As Object, conn As SQL, ws As WebSocket, EventName As String)
    parObj = Parent
    sEv = EventName
    wslocal = ws
    connLocal = conn
End Sub

Public Sub setPaginationID(PaginationListID As String)
    ulist = wslocal.GetElementById(PaginationListID)
    PaginationIDLocal = PaginationListID
End Sub

Public Sub ulist_Click(Params As Map)
    Log(Params)
End Sub
 
Last edited:

teddybear

Well-Known Member
Licensed User
1.What is the ulist in the HTML page, is it a li?
2.Where is the setPaginationID called ?
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
The ulist is an unordered list which contains multiple li tags which each of them includes an <a> tag.
I have managed to get around this problem by creating in the websocket class connected to the server the appropriate ulnameoflist_Click (Params As Map) sub and from it call the class.ulist_Click(Params). If though it could be done directly I would be very interested in learning how it can be done.

Edit - the setPaginationID is called from the websocket class connected to the server.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Why do you need to create a new jqueryelement ulist using GetElementById? it is different from PagationListID of HTML pages. although the event ulist_click has been added by wsconnetion, there is no the ulist element to bind it on the web page .
 
Upvote 0
Top