Skip to content

Commit

Permalink
Fixes switching back and fort between simple and visual editor.
Browse files Browse the repository at this point in the history
When switching back and fort from visual editor to simple editor, data would still appear in the ckeditor but was never sent to server. It seems that using CKEDITOR.instances.page__body_editor.setData() was not enough as the page__body_editor hidden textarea had to be filled in first.
  • Loading branch information
fdevillamil committed Oct 19, 2011
1 parent d41bfcc commit 53f7cb0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
7 changes: 7 additions & 0 deletions app/views/admin/content/_simple_editor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
$('s').className = 'active';
$('f').className = '';
$('text_filter').value = $('user_textfilter').value;

content = CKEDITOR.instances.article__body_and_extended_editor.getData();

if (CKEDITOR.instances.article__body_and_extended_editor &&
typeof(CKEDITOR.instances.article__body_and_extended_editor) == 'object') {
delete(CKEDITOR.instances.article__body_and_extended_editor);
}

</script>
<%= text_area('article', 'body_and_extended', {:class => 'large', :height => '300px', :rows => '20'}) %>
<script type="text/javascript">
Expand Down
8 changes: 3 additions & 5 deletions app/views/admin/content/_visual_editor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
if ($('carousel-wrapper')) {
$('carousel-wrapper').style.display = 'none';
}
$('article__body_and_extended_editor').value = html;

if (CKEDITOR.instances.article__body_and_extended_editor &&
typeof(CKEDITOR.instances.article__body_and_extended_editor) == 'object') {
delete(CKEDITOR.instances.article__body_and_extended_editor);
}
</script>
<%= ckeditor_textarea('article', 'body_and_extended', {:height => '300', :class => 'large'}) %>
<script type="text/javascript">
content = CKEDITOR.instances.article__body_and_extended_editor.setData(html);
CKEDITOR.instances.article__body_and_extended_editor.setData(html);

</script>
4 changes: 4 additions & 0 deletions app/views/admin/pages/_simple_editor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
$('f').className = 'inactive';
$('text_filter').value = $('user_textfilter').value;
content = CKEDITOR.instances.page__body_editor.getData();
if (CKEDITOR.instances.page__body_editor &&
typeof(CKEDITOR.instances.page__body_editor) == 'object') {
delete(CKEDITOR.instances.page__body_editor);
}
</script>
<%= text_area('page', 'body', {:class => 'large', :height => '300px', :rows => '20'}) %>
<script type="text/javascript">
Expand Down
7 changes: 1 addition & 6 deletions app/views/admin/pages/_visual_editor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
html = $('page_body').value;
$('simple_editor').innerHTML = '';
$('carousel-wrapper').style.display = 'none';

if (CKEDITOR.instances.page__body_editor &&
typeof(CKEDITOR.instances.page__body_editor) == 'object') {
delete(CKEDITOR.instances.page__body_editor);
}

$('page__body_editor').value = html;
</script>
<%= ckeditor_textarea('page', 'body', {:height => '300', :class => 'large'}) %>
<script type="text/javascript">
Expand Down

0 comments on commit 53f7cb0

Please sign in to comment.