my JS function is not included in the Javascript generated
When I first tried your example, I had the same. I then created a new ABM B4JS class (Project - Add New Module - Class Module - ABM B4JS, copied your code in it at then it did generate. I honestly have no idea why it didn't the first time.
Couple of notes:
1. First, do not add an initialize method in the B4JS class. My B4JSBinder class looks like this:
'Class module
Sub Class_Globals
' use Public or Dim if you want to share this variable over ALL B4JS classes
' use Private if only within this class
Public ABM As ABMaterial 'ignore, just to access the constants
Public Page As ABMPage 'ignore, just to be able to run ABMPage B4JS functions
End Sub
'Initializes the object. You can NOT add parameters to this method.
'MUST be called InitializeB4JS is automatically called when using this class
Public Sub InitializeB4JS
End Sub
#if JAVASCRIPT
function bindkeyupToB4J(htmlElement, b4jSub) {
$(htmlElement).keyup(function() {
var elementValue = $(htmlElement).val();
b4j_raiseEvent(b4jSub, {"inputValue": elementValue})
});
}
#End If
2. You must run the page.B4JSRunInlineJavascriptMethod AFTER page.Refresh. If you run it before, the Input is not yet added to the page so the javascript method does nothing. Also use .ToLowerCase as the generated html/js IDs will be lowercased too.
...
Dim InpLat1 As ABMInput
InpLat1.Initialize(page, "inpLat1", ABM.INPUT_TEXT, "From Latitude", False , "input")
page.Cell(3,1).AddComponent(InpLat1)
' refresh the page
page.Refresh
' Tell the browser we finished loading
page.FinishedLoading
' restoring the navigation bar position
page.RestoreNavigationBarPosition
' now you can run this method as the InpLat1 component is added
page.B4JSRunInlineJavascriptMethod("bindkeyupToB4J", Array("#inpLat1".ToLowerCase, "inpLat1_MyKeyUp".ToLowerCase))
End Sub
Now I receive on my page in Sub InpLat1_MyKeyUp(m As Map):
inputValue: 1
inputValue: 12
inputValue: 123
inputValue: 1234
inputValue: 12345
inputValue: 123456
inputValue: 1234567
inputValue: 12345678
inputValue: 123456789
Note this is just to demonstrate how B4JS works, but with just ABM, you can archive the same using the Changed event. By default this event is off (because going back and forth to the server for each key press on the browser side is bad: it will stress your server traffic enormously). But if you really, really, really want it, you can activate it with:
Dim InpLat1 As ABMInput
InpLat1.Initialize(page, "inpLat1", ABM.INPUT_TEXT, "From Latitude", False , "input")
InpLat1.RaiseChangedEvent = True ' <-------------------
page.Cell(3,1).AddComponent(InpLat1)
...
Sub InpLat1_Changed(value As String)
Log(value)
End Sub
Alain