B4J Question [BANano] run a function in js

micro

Well-Known Member
Licensed User
Longtime User
Hi to all
Excuse me but I'm still not very mature in creating web apps.
I have a Toast.js, a simply file that customizes and displays toaster messages
https://www.cssscript.com/super-simple-javascript-message-toaster-toast-js/
after starting the program the three files (toast.js, toast.min.js and toast.mod.js) are copied into Scripts folder.
....here I have a lot of confusion :confused:
In BANano_Ready, i put
B4X:
#if Javascript
function toastshow(text)
{
    var toast = new iqwerty.toast.Toast();
    toast.setText(text)
    .setDuration(3000)
    .show();
}
#End If

And for call this function:
B4X:
BANano.RunJavascriptMethod("toastshow", Array As String("Hello!"))
but I don't see anything, where am I wrong?

Thanks for your tips
 

Kiffi

Well-Known Member
Licensed User
Longtime User
You do not need the inline code.

just execute:
B4X:
BANano.RunJavascriptMethod("iqwerty.toast.Toast", Array( "Hello" ) )

or, if you want to use the options:
B4X:
Dim myOptions As Map = CreateMap()

Dim mySettings As Map = CreateMap()

mySettings.Put("duration", 1000)

myOptions.Put("settings", mySettings)

BANano.RunJavascriptMethod("iqwerty.toast.Toast", Array( "Hello", myOptions ) )

Further informations: https://github.com/mlcheng/js-toast

Greetings ... Peter
 
Upvote 0
Top