From 50386923b6f400b0b099f4abeda356fa69805cdc Mon Sep 17 00:00:00 2001 From: totoro Date: Sun, 23 Oct 2022 17:50:30 +0200 Subject: [PATCH] add call back in img_button_confirm which be called after the web_action. For example after a web_action executed, refresh the page (which made by the call back) --- web/widgets/button.anubis | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/widgets/button.anubis b/web/widgets/button.anubis index be1bfae..15b108a 100644 --- a/web/widgets/button.anubis +++ b/web/widgets/button.anubis @@ -249,12 +249,15 @@ define List(CoreAttrs) String uid, WEB_Action_Name web_action, List((String, String)) extra_ops, - String load_content_target + String load_content_target, + String call_back ) = //action to execute if confirmation is ok with ok_action = if load_content_target = "" then - to_JS_String("Xlib.jq_query("+format_web_action_name_to_js(web_action, extra_ops)+")") + with call_back_js = if call_back = "" then "" else + ", undefined, "+to_JS_String(call_back), + to_JS_String("Xlib.jq_query("+format_web_action_name_to_js(web_action, extra_ops) + call_back_js+")") else load_content_JS_String(load_content_target, web_action, extra_ops, true, true), //to_JS_String("Xlib.load_content('"++"', "+format_web_action_name_to_js(web_action, extra_ops)+", true)"), @@ -345,12 +348,13 @@ public define HTML_Partial_Content WEB_Action_Name web_action, List((String, String)) extra_ops, String load_content_target //if empty doesn't use load content + String call_back //callback to execute after the web action ) = with uid = generate_random_string(20), //with event_click = (CoreAttrs)event(onclick, "Xlib.jq_query("+format_web_action_name_to_js(web_action, extra_ops)+")"), partial_content([js(js_file("xlib/js/xlib.js")), js_inline(jquery_ready(img_button_confirm_js(uid, dlg_title, dlg_text, dlg_ok, dlg_cancel)))], - img(img_button_confirm_image_attrs(core_attrs, uid, web_action, extra_ops, load_content_target), img_path)) + img(img_button_confirm_image_attrs(core_attrs, uid, web_action, extra_ops, load_content_target, call_back), img_path)) . public define HTML_Partial_Content @@ -365,5 +369,5 @@ public define HTML_Partial_Content WEB_Action_Name web_action, List((String, String)) extra_ops ) = - img_button_confirm(img_path, core_attrs, dlg_title, dlg_text, dlg_ok, dlg_cancel, web_action, extra_ops, "") + img_button_confirm(img_path, core_attrs, dlg_title, dlg_text, dlg_ok, dlg_cancel, web_action, extra_ops, "", "") . -- libgit2 0.21.4