ckeditor的jquery插件怎么用?(包括取值,实例化等)
1个回答
展开全部
参考ckeditor的samples\jqueryadapter.html
加载js:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script type="text/javascript" src="editor/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="editor/ckeditor/adapters/jquery.js"></script>
<script type="text/javascript">
//<![CDATA[
$(function()
{
var config = {
toolbar:
[
['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink'],
['UIColor']
]
};
// Initialize the editor.
// Callback function can be passed and executed after full instance creation.
$('#jquery_ckeditor').ckeditor(config);
});
//]]>
</script>
如果直接用可以这样:
var ckeditor = $('#jquery_ckeditor').data( 'ckeditorInstance' );
ckeditor.setData( newValue );
editor.getData();
如果将CKEDITOR.config.jqueryOverrideVal设为true重定义val,则可以直接通过$('#jquery_ckeditor').val( [newValue] )赋值取值。
其实你看一下_source\adapters\jquery.js和_samples\jqueryadapter.html就什么都明白了。
加载js:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script type="text/javascript" src="editor/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="editor/ckeditor/adapters/jquery.js"></script>
<script type="text/javascript">
//<![CDATA[
$(function()
{
var config = {
toolbar:
[
['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink'],
['UIColor']
]
};
// Initialize the editor.
// Callback function can be passed and executed after full instance creation.
$('#jquery_ckeditor').ckeditor(config);
});
//]]>
</script>
如果直接用可以这样:
var ckeditor = $('#jquery_ckeditor').data( 'ckeditorInstance' );
ckeditor.setData( newValue );
editor.getData();
如果将CKEDITOR.config.jqueryOverrideVal设为true重定义val,则可以直接通过$('#jquery_ckeditor').val( [newValue] )赋值取值。
其实你看一下_source\adapters\jquery.js和_samples\jqueryadapter.html就什么都明白了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询