这个 TinyMCE 插件是从 wordcount 插件派生的,当字符数超过设置限制时也会显示错误消息。但它不起作用。每次更新操作addClass
和removeClass
功能都找不到。我稍微编辑了代码,但核心是相同的:
// on init
var statusbar = editor.theme.panel && editor.theme.panel.find('#statusbar')[0];
if (statusbar) {
tinymce.util.Delay.setEditorTimeout(editor, function() {
statusbar.insert({
type: 'label',
name: 'maxlength',
text: ['Length: {0}', self.getCharCount()],
classes: 'wordcount',
disabled: editor.settings.readonly
}, 0);
...
// on update
var wc = editor.theme.panel.find('#maxlength');
wc[0].removeClass('danger'); // Error!
如何解决?
编辑: console.log(wc[0])
输出:
t {_super: undefined, settings: Object, _id: "mceu_160", _aria: Object, _elmCache: Object…}
$: function f(e,t)
arguments: [Exception: TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context...]
attrHooks: Object
caller: [Exception: TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context...]
contains: function (e,t)
cssHooks: Object
each: function m(e,t)
expr: Object
extend: function s(e,n)
filter: function (e,t,n)
find: function e(e,t,n,r)
fn: f[0]
grep: function g(e,t)
inArray: function h(e,t)
isArray: function isArray()
length: 2
makeArray: function (e)
name: "f"
overrideDefaults: function (e)
prototype: f[0]
text: function (e)
trim: function p(e)
unique: function (e)
__proto__: function ()
<function scope>
$el: f.fn.f.init[1]
_aria: Object
_elmCache: Object
_eventDispatcher: t
_eventsRoot: t
_id: "mceu_160"
_name: "wordcount"
_nativeEvents: Object
_parent: t
_super: undefined
borderBox: undefined
canFocus: false
classes: n
data: t
marginBox: undefined
paddingBox: undefined
rootControl: t
settings: Object
state: t
type: "label"
__proto__: t