B4J Question [WebApp] Seeking Confirmation & Input Dialog examples

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

in the WebApp examples, there is an example of how to use a ShowDialog, like
B4X:
Dialog.RunMethod("dialog", Array As Object(CreateMap("autoOpen": False, "modal": True)))
Dialog.SetHtml("I'am a dialog")
Dialog.RunMethod("dialog", Array As Object("option", "title", "Dialog Title"))
Dialog.RunMethod("dialog", Array As Object("open"))

Question: Are there examples for Confirmation and Input Dialogs including handling return values from these dialogs.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Create the dialog in the html file instead of WebSocket_Connected:
B4X:
$( document ).ready(function() {
     
     $( "#dialog" ).dialog({
       resizable: false,
       height:240,
       modal: true,
       autoOpen: false,
       buttons: {
         "Yes": function() {
           b4j_raiseEvent("dialog_event", {"result": "yes"});
           $( this ).dialog( "close" );
         },
         "No": function() {
           b4j_raiseEvent("dialog_event", {"result": "no"});
           $( this ).dialog( "close" );
         }
       }
     });
     b4j_connect("/datepicker/ws");
}

In your B4J code:
B4X:
Sub Dialog_Event(Params As Map)
   Log("Result = " & Params.Get("result"))
End Sub

Note that the events names in the html file must be lower-case.
 
Upvote 0
Top