Commit 2c3918d50e39f154076525d5bdf90ccb45264cae

Authored by David RENÉ
1 parent 456d0986

[~] 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
Showing 1 changed file with 12 additions and 7 deletions   Show diff stats
view/view_table_renderer.anubis
... ... @@ -791,7 +791,7 @@ public define List(CXM_Form_Field)
791 791 one_line_fields([
792 792  
793 793 message(to_String(format_label(label(_T(s_name), no_help), html_Id("")))+
794   - "<input class=\"in\" id=\""+uid+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"),
  794 + "<input class=\"in\" id=\""+uid+"\" data-combo_search=\""+c_name+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"),
795 795 if no_add then
796 796 empty
797 797 else
... ... @@ -804,19 +804,22 @@ public define List(CXM_Form_Field)
804 804 [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)],
805 805  
806 806 text_area(s_name, c_name, value, txt_editor, help) then
807   - with uid = "_"+generate_random_string(20),
808   - with id = if txt_editor is { none then "", rich_editor then uid+"_editor"},
  807 +// with uid = "_"+generate_random_string(20),
  808 +// with id = if txt_editor is { none then "", rich_editor then uid+"_editor"},
809 809 [
810 810 if txt_editor is {
811 811 none then empty,
812 812 rich_editor then partial(partial_content(
813 813 [ js(js_file("ckeditor/ckeditor.js")),
814 814 js_inline(jquery_ready(
815   - " var cke_instance = CKEDITOR.replace( '"+id+"' );
816   - cke_instance.on('blur', function() { cke_instance.updateElement(); });
  815 + " console.log('loading CKeditor for "+c_name+"');
  816 + if(CKEDITOR.instances."+c_name+")
  817 + CKEDITOR.instances."+c_name+".destroy(true);
  818 + var cke_instance = CKEDITOR.replace( '"+c_name+"' );
  819 + cke_instance.on('blur', function() { cke_instance.updateElement(); });
817 820 "))],empty))
818 821 },
819   - 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)
  822 + 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)
820 823 ],
821 824  
822 825 boolean(s_name, c_name, value, help) then
... ... @@ -1065,7 +1068,9 @@ public define List(CXM_Form_Field)
1065 1068 rich_editor then partial(partial_content(
1066 1069 [js(js_file("ckeditor/ckeditor.js")),
1067 1070 js_inline(jquery_ready(
1068   - " console.log('loading CKeditor');
  1071 + " console.log('loading CKeditor for "+c_name+"');
  1072 + if(CKEDITOR.instances."+c_name+")
  1073 + CKEDITOR.instances."+c_name+".destroy(true);
1069 1074 var cke_instance = CKEDITOR.replace( '"+c_name+"' );"+
1070 1075 //" var cke_instance = CKEDITOR.replace( '"+id+"' );
1071 1076 " cke_instance.on('blur', function() { cke_instance.updateElement(); });
... ...