rwblinn Well-Known Member Licensed User Longtime User Apr 17, 2014 #1 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.
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 Apr 17, 2014 #2 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
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.
rwblinn Well-Known Member Licensed User Longtime User Apr 17, 2014 #3 Thanks a lot. Have build a sample HOWTO with first dialogs: Alert, Confirm and Input. More to follow. Download: http://www.rwblinn.de/b4j/b4jhowto/examples/b4jhowtowebappdialogsui.zip Upvote 0
Thanks a lot. Have build a sample HOWTO with first dialogs: Alert, Confirm and Input. More to follow. Download: http://www.rwblinn.de/b4j/b4jhowto/examples/b4jhowtowebappdialogsui.zip