Javascript 在pageload上设置CKEditor工具栏配置会导致未捕获的TypeError:undefined不是一个函数
我定义了多个工具栏,默认工具栏当前是通过Javascript 在pageload上设置CKEditor工具栏配置会导致未捕获的TypeError:undefined不是一个函数,javascript,jquery,ckeditor,toolbar,Javascript,Jquery,Ckeditor,Toolbar,我定义了多个工具栏,默认工具栏当前是通过config.toolbar='MyToolbar'定义的MyToolbar 但是如何在pageload上选择这些配置 我尝试了$('#TextBox1').ckeditor(函数(){},{toolbar:'Basic'}) 正如这里所建议的 但这不会覆盖默认的MyToolbar。我还尝试删除了config.toolbar='MyToolbar'
config.toolbar='MyToolbar'定义的MyToolbar
代码>
但是如何在pageload上选择这些配置
我尝试了$('#TextBox1').ckeditor(函数(){},{toolbar:'Basic'})代码>
正如这里所建议的
但这不会覆盖默认的MyToolbar。我还尝试删除了config.toolbar='MyToolbar'但是没有运气
我得到了未捕获的TypeError:undefined不是控制台中的函数,但我不知道为什么
我目前有以下代码,其中显示了默认的CKEditor实例:
<script src="/ckeditor/ckeditor.js"></script>
<asp:TextBox ID="TextBox1" ClientIDMode="Static" CssClass="ckeditor" TextMode="MultiLine" runat="server"></asp:TextBox>
更新
我忘了输入
。如下所述:
它现在可以工作了。这很奇怪,因为你似乎做得对。传递给CKEditor creator方法的配置优先于加载的配置文件。你能不能创建一个示例来说明这个问题,因为这个方法对我来说绝对有效?看看JS控制台。您的代码会抛出错误。这就是它不起作用的原因。@Reinmar:我看到的唯一一个是Uncaught TypeError:undefined不是我调用.ckeditor
的行中的函数,但我看不到如何解决这个问题,因为我在调用该方法之前包含了ckeditor.js
文件。但是你是否包含jQuery适配器文件?阅读更多的文章。@Reinmar:就是这样,谢谢。
CKEDITOR.editorConfig = function (config) {
config.toolbar = 'MyToolbar';
config.toolbar_MyToolbar =
[
{ name: 'document', items: ['NewPage', 'Preview'] },
{ name: 'clipboard', items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
{ name: 'editing', items: ['Find', 'Replace', '-', 'SelectAll', '-', 'Scayt'] },
{
name: 'insert', items: ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak'
, 'Iframe']
},
'/',
{ name: 'styles', items: ['Styles', 'Format'] },
{ name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', '-', 'RemoveFormat'] },
{ name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote'] },
{ name: 'links', items: ['Link', 'Unlink', 'Anchor'] },
{ name: 'tools', items: ['Maximize', '-', 'About'] }
];
config.toolbar_Full =
[
{ name: 'document', items: ['Source', '-', 'Save', 'NewPage', 'DocProps', 'Preview', 'Print', '-', 'Templates'] },
{ name: 'clipboard', items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
{ name: 'editing', items: ['Find', 'Replace', '-', 'SelectAll', '-', 'SpellChecker', 'Scayt'] },
{
name: 'forms', items: ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton',
'HiddenField']
},
'/',
{ name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'] },
{
name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv',
'-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl']
},
{ name: 'links', items: ['Link', 'Unlink', 'Anchor'] },
{ name: 'insert', items: ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe'] },
'/',
{ name: 'styles', items: ['Styles', 'Format', 'Font', 'FontSize'] },
{ name: 'colors', items: ['TextColor', 'BGColor'] },
{ name: 'tools', items: ['Maximize', 'ShowBlocks', '-', 'About'] }
];
config.toolbar_Basic =
[
['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink', '-', 'About']
];
};