我使用的是CKEditor。我使用页面方法通过ajax保存表单值。
但是CKEditor值的内容不能保存到表中。
我不回传这个页面。
我能为此做些什么呢?
发布于 2010-09-27 03:17:44
首先,您应该在页面中包含ckeditor和jquery连接器脚本,
然后创建一个文本区
<textarea name="content" class="editor" id="ms_editor"></textarea>将ckeditor附加到文本区域,在我的项目中,我使用了如下内容:
$('textarea.editor').ckeditor(function() {
}, { toolbar : [
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
['Undo','Redo'],
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Link','Unlink','Anchor', 'Image', 'Smiley'],
['Table','HorizontalRule','SpecialChar'],
['Styles','BGColor']
], toolbarCanCollapse:false, height: '300px', scayt_sLang: 'pt_PT', uiColor : '#EBEBEB' } );在提交时,使用以下命令获取内容:
var content = $( 'textarea.editor' ).val();就是这样!:)
发布于 2010-12-18 04:45:25
在实例上使用CKEditor.editor.getData()调用。也就是说:
HTML
<textarea id="my-editor">
<input id="send" type="button" value="Send">用于CKEditor 4.0.x的JS
$('#send').click(function() {
var value = CKEDITOR.instances['DOM-ID-HERE'].getData()
// send your ajax request with value
// profit!
});CKEditor 3.6.x的JS
var editor = CKEDITOR.editor.replace('my-editor');
$('#send').click(function() {
var value = editor.getData();
// send your ajax request with value
// profit!
});发布于 2011-12-20 02:51:35
如果你没有引用编辑器,就像在Aeon的回答中一样,你也可以使用下面的形式:
var value = CKEDITOR.instances['my-editor'].getData();https://stackoverflow.com/questions/3799317
复制相似问题