0

How can I convert the JavaScript code below to jQuery? I'm not a JavaScript or jQuery expert.

Here is the JavaScript code.

CKEDITOR.on('instanceReady', function( ev ) {
  var blockTags = ['div','h1','h2','h3','h4','h5','h6','p','pre','li','blockquote','ul','ol',
  'table','thead','tbody','tfoot','td','th',];

  for (var i = 0; i < blockTags.length; i++)
  {
     ev.editor.dataProcessor.writer.setRules( blockTags[i], {
        indent : false,
        breakBeforeOpen : true,
        breakAfterOpen : false,
        breakBeforeClose : false,
        breakAfterClose : true
     });
  }
});
2
  • 2
    Jquery is still Javascript so why change it? What do you want to archive? Commented Feb 15, 2012 at 8:02
  • Just for the heck of it, I Googled 'jquery for ckeditor'. I didn't look at any of the results, but it appears there are one or more jquery plugins for ckeditor. Commented Feb 15, 2012 at 8:17

2 Answers 2

4

I wouldn't change this to JQuery as it has nothing to do with the DOM, DOM manipulation or DOM traversal.

It's only configuring the CKEditor, and JQuery can't help with that...

Sign up to request clarification or add additional context in comments.

Comments

1

You could put it in the JQuery $(document).ready() function without having to change the code at all

$(document).ready(function() {
    CKEDITOR.on('instanceReady', function( ev ) {
      var blockTags = ['div','h1','h2','h3','h4','h5','h6','p','pre','li','blockquote','ul','ol','table','thead','tbody','tfoot','td','th',];

      for (var i = 0; i < blockTags.length; i++)
      {
         ev.editor.dataProcessor.writer.setRules( blockTags[i], {
            indent : false,
            breakBeforeOpen : true,
            breakAfterOpen : false,
            breakBeforeClose : false,
            breakAfterClose : true
         });
      }
    });
});

This will affect all instances of CKeditor if that is what you want.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.