0

I'd like to override (wrap) the $.fn.ckeditor function, that is the jQuery adapter for CKEditor. What value should I return? It this the correct way:

;(function ($) {
    var defaults = {}
        ckeditor = $.fn.ckeditor;

    $.fn.ckeditor = function (cb, options) {                   
        ckeditor.apply(this, [cb || $.noop, $.extend(defaults, options || {})]);
    };
}(jQuery));

in order to override a plugin?

gremo
  • 47,186
  • 75
  • 257
  • 421

1 Answers1

0

Note Not tried ckeditor (plugin).

If interpret post accurately,

Try this (pattern)

html

<article>123</article>
<div>123</div>
<span>123</span>

js

$(function () {;
    (function ($) {
        $.fn.ckeditor = function (options) {
                    var defaults = {
            "n": 2
        };
            var options = $.extend({}, defaults, options);
            return $(this).html(function (index, o) {
                return String(Number(o) * options.n)
            })
        };
    }(jQuery));

    $("article").ckeditor();

    $("div").ckeditor({
        "n": 4
    });

    $("span").ckeditor({
        "n": (function () {
            return Number($("article").html())
        })()
    });
})

jsfiddle http://jsfiddle.net/guest271314/2qrq3/

See jQuery fn.extend ({bla: function(){}} vs. jQuery.fn.bla

Community
  • 1
  • 1
guest271314
  • 1
  • 15
  • 104
  • 177