From 5f98667f7388f11de28a3b4f7bc842e41677f48c Mon Sep 17 00:00:00 2001 From: totoro Date: Mon, 12 Jun 2017 02:09:43 +0200 Subject: [PATCH] add to_html_ajax_content into maiking a web site which allow to format an HTML content directly into JSON format ready to be sent through AJAX call add call_back as argument to jq_form_submit_and_close. This call back is fired just after the closing dialog. This can call refresh function or anything else. --- web/CXM_making_a_web_site.anubis | 31 +++++++++++++++++++++++++++++++ web/jQuery/CXM_jq_form.anubis | 7 ++++--- web/jQuery/ui-addon/datetimepicker.anubis | 2 +- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis index 31c497f..5bdc102 100644 --- a/web/CXM_making_a_web_site.anubis +++ b/web/CXM_making_a_web_site.anubis @@ -5905,6 +5905,37 @@ public define HTML_ajax_content CommonInfo cinfo )= to_html_ajax_content(partial(content_HTML), cinfo). +public define JsonValue + to_html_ajax_content + ( + HTML_Partial_Content content_HTML, + CommonInfo cinfo, + String additional_script + )= + since to_html_ajax_content(partial(content_HTML), cinfo) is html_ajax_content(html, script, js_files, css_files), + json_object([ + json_member("html", json_string(html)), + json_member("js_files", to_json_array(js_files)), + json_member("css_files", to_json_array(css_files)), + json_member("script", json_string(additional_script+script)), + ]) +. + +public define JsonValue + to_html_ajax_content + ( + Printable_tree content_HTML, + String additional_script + )= + //since to_html_ajax_content(partial(content_HTML), cinfo) is html_ajax_content(html, script, js_files, css_files), + json_object([ + json_member("html", json_string(to_String(content_HTML))), + json_member("js_files", to_json_array([])), + json_member("css_files", to_json_array([])), + json_member("script", json_string(additional_script)), + ]) +. + public define Printable_tree format ( diff --git a/web/jQuery/CXM_jq_form.anubis b/web/jQuery/CXM_jq_form.anubis index 7d61c2c..e02c1ab 100644 --- a/web/jQuery/CXM_jq_form.anubis +++ b/web/jQuery/CXM_jq_form.anubis @@ -28,10 +28,11 @@ public define String String dialog_id, String form_id, //id of the form ID handled by this function WEB_Action_Name action, - List((String,String)) extra_ops - + List((String,String)) extra_ops, + String call_back //call to execute after )= with dialog_id_str = if length(dialog_id) > 0 then ", '" + dialog_id + "'" else "", + with call_back_str = if length(call_back) > 0 then ", "+call_back else "", with url = format_web_action_name(action, extra_ops), - "CalexiumToolBox.jq_form_submit_and_close('" + form_id + "', '" + url + "'"+dialog_id_str+");" + "CalexiumToolBox.jq_form_submit_and_close('" + form_id + "', '" + url + "'"+dialog_id_str+call_back_str+");" . diff --git a/web/jQuery/ui-addon/datetimepicker.anubis b/web/jQuery/ui-addon/datetimepicker.anubis index a31e734..96cbbaa 100644 --- a/web/jQuery/ui-addon/datetimepicker.anubis +++ b/web/jQuery/ui-addon/datetimepicker.anubis @@ -28,7 +28,7 @@ public define String ( String lang, Bool add_icon - ) = "// Datetimepicker\n + ) = " $.datetimepicker.setLocale('"+lang+"'); $('.datepicker').datetimepicker({timepicker:false,format:'Y-m-d'}); $('.datetimepicker').datetimepicker({format:'Y-m-d H:i'}); -- libgit2 0.21.4