From 2c3918d50e39f154076525d5bdf90ccb45264cae Mon Sep 17 00:00:00 2001 From: totoro Date: Sat, 27 Nov 2021 08:11:46 +0100 Subject: [PATCH] [~] replace the random uid of ckeditor by the c_name which is the column name of the database. This is useful because the name is predictable and the CKEDITOR can be destroyed easily --- view/view_table_renderer.anubis | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/view/view_table_renderer.anubis b/view/view_table_renderer.anubis index a79a9c3..e694295 100644 --- a/view/view_table_renderer.anubis +++ b/view/view_table_renderer.anubis @@ -791,7 +791,7 @@ public define List(CXM_Form_Field) one_line_fields([ message(to_String(format_label(label(_T(s_name), no_help), html_Id("")))+ - ""), + ""), if no_add then empty else @@ -804,19 +804,22 @@ public define List(CXM_Form_Field) [selector_c([],label(_T(s_name), no_help), html_Id(""), wan(c_name), 1, select.get(db, no_referer, ""), success(init(value)), mandatory), help_line(help, _T)], text_area(s_name, c_name, value, txt_editor, help) then - with uid = "_"+generate_random_string(20), - with id = if txt_editor is { none then "", rich_editor then uid+"_editor"}, +// with uid = "_"+generate_random_string(20), +// with id = if txt_editor is { none then "", rich_editor then uid+"_editor"}, [ if txt_editor is { none then empty, rich_editor then partial(partial_content( [ js(js_file("ckeditor/ckeditor.js")), js_inline(jquery_ready( - " var cke_instance = CKEDITOR.replace( '"+id+"' ); - cke_instance.on('blur', function() { cke_instance.updateElement(); }); + " console.log('loading CKeditor for "+c_name+"'); + if(CKEDITOR.instances."+c_name+") + CKEDITOR.instances."+c_name+".destroy(true); + var cke_instance = CKEDITOR.replace( '"+c_name+"' ); + cke_instance.on('blur', function() { cke_instance.updateElement(); }); "))],empty)) }, - text_area([],label(_T(s_name), no_help), html_Id(id), wan(c_name), init(not_null_String(value)), narrow, (Int)5, mandatory), help_line(help, _T) + text_area([],label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(not_null_String(value)), narrow, (Int)5, mandatory), help_line(help, _T) ], boolean(s_name, c_name, value, help) then @@ -1065,7 +1068,9 @@ public define List(CXM_Form_Field) rich_editor then partial(partial_content( [js(js_file("ckeditor/ckeditor.js")), js_inline(jquery_ready( - " console.log('loading CKeditor'); + " console.log('loading CKeditor for "+c_name+"'); + if(CKEDITOR.instances."+c_name+") + CKEDITOR.instances."+c_name+".destroy(true); var cke_instance = CKEDITOR.replace( '"+c_name+"' );"+ //" var cke_instance = CKEDITOR.replace( '"+id+"' ); " cke_instance.on('blur', function() { cke_instance.updateElement(); }); -- libgit2 0.21.4