Reputation: 986
I'm Looking to disable a button outside of CKEditor during Source view. I've tried it many different ways, but can't seem to get it right.
My code:
var CKE = CKEDITOR.instances.textarea;
CKE.setData(decodeURIComponent(htmlTEXT), function () {
this.checkDirty();
});
CKEDITOR.on('key', function (ev) {
var state = ev.editor.getCommand('source').state;
console.log(state);
if (state == true)
{
// disable button
}
});
Upvotes: 1
Views: 1515
Reputation: 986
Thanks for the help. I ended up making a function to check the mode for 'source'.
function checkSource() {
if (CKEDITOR.instances.textarea.mode == 'source'){
// this will disable the save button while in 'Source' mode.
$('#SaveBtn').attr('disabled', 'disabled');
}
else{
$('#SaveBtn').removeAttr('disabled', 'disabled');;
}
Upvotes: 0
Reputation: 15895
Use CKEDITOR.editor#mode
event listener (JSFiddle):
CKEDITOR.replace( 'my-editor', {
toolbarGroups: [
{"name":"document","groups":["mode"]},
{"name":"basicstyles","groups":["basicstyles"]}
],
on: {
instanceReady: function() {
this.on( 'mode', function() {
console.log( this.name + ' works in ' + this.mode + ' mode' );
} );
}
}
} );
Upvotes: 2