fishme / kirby_ckeditor

Visual Editor for Kirby2
GNU General Public License v2.0
10 stars 1 forks source link

Dropdown not working after saving #7

Open kelvinau opened 6 years ago

kelvinau commented 6 years ago

Dropdowns of Formatting Styles, Paragraph Format, Font Name, and Font Size cannot be opened after saving. They work fine before that. Now I need to refresh the page to use it properly.

kelvinau commented 6 years ago

Found out that it's related to this line https://github.com/fishme/kirby_ckeditor/blob/4bb72e518d24450ecdbc80d725f34804d69441ab/ckeditor.php#L50 A new DOM with the same ID is appended every time after saving. For a quick fix, removing the previous element will solve it, like this

$wrapper->append('
            <script src="'.str_replace('/panel/index.php','',$_SERVER['SCRIPT_NAME']) . '/site/fields/ckeditor/assets/js/ckeditor.js"></script>
            <script>
                $("#cke_form-field-' . $this->name() . '").remove();
                CKEDITOR.inline( "'.$this->name().'" );
            </script>
        ');