How to cure js error "is not a function"?

  • 0
    Please tell me why the error occurs.

    There is a well-known plugin Colorbox.
    But it's not adaptive out of the box.
    There is a fix for this. Added to the site along with colorbox. And order.

    // Адаптивный ColorBox
    $.colorbox.settings.maxWidth = '95%';
    $.colorbox.settings.maxHeight = '95%';
    Функция ресайза ColorBox
    var resizeTimer;
    function resizeColorBox()
      if (resizeTimer) clearTimeout(resizeTimer);
      resizeTimer = setTimeout(function() {
        if ($('#cboxOverlay').is(':visible')) {
      }, 300);
    Ресайз при изменении размера окна браузера и изменении ориентации мобильного устройства
    window.addEventListener("orientationchange", resizeColorBox, false);

    But there is one problem in it, if you open a picture through the colorbox and resize the window, the resize function does not work, it hits an error in the console on this line.
    $. colorbox.load (true);
    Here is an Uncaught TypeError: $ .colorbox.load is not a function

    They say there is no such function, what is wrong? I don't understand how to treat :(

    Here is a live example.
    JavaScript Isaac Russell, Apr 6, 2019

  • 0 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!