@Happymalina

Что значит Cannot read property 'find' of undefined в консоли?

Привет. Не сильна в js на столько чтобы понять почему не срабатывает скопированный код плагина. Именно скопированный потому что сам плагин требует использования jade и препроцессоров. Нужно было обойтись без них и прикрутить к html и сss. Вот этот инструмент https://github.com/hugeinc/styleguide и вот демо на их стайлгайд http://hugeinc.github.io/styleguide/demo/index.html.
В общем я почти закончила, но столкнулась с проблемой, при выборе пункта меню в сайдбаре не совершается переход и поиск модуля во фрейме. Так как я только учу js решила проверить по кускам из скрипта.
Вставила в консоль
var top = this.$iframeContent.find('section' + $elem.attr('href')).offset().top + 50;

Консоль выдала ошибку Cannot read property 'find' of undefined.. большая предыстория и маленький вопрос - что это может значить?
ну и вот кусок кода из скрипта, который отвечает за переход к модулю с якорем. Может быть подкините идею что еще может быть не так..
/**
     * Check URL hash and navigate
     * to the respective module
     */
    checkHashOnLoad: function() {

        // Shutdown this feature in Chrome.
        // Chrome have a know issue with file protocol and iframe comunication.
        // It is not supported so we should not raise errors.

        if(this.isChromeAndFileProtocol()) return false;
        if (window.location.hash === '#' || window.location.hash === '') return false;

        var top = this.$iframeContent.find('section' + window.location.hash.replace('!', '')).offset().top,
            $iframeHtmlBody = this.$iframeContent.find('html, body');

        if (this.$iframeContent.find('section' + window.location.hash.replace('!', '')).index() === 0) {
            $(window).load(function() {
                $iframeHtmlBody.animate({scrollTop: 0}, 500);
            });
        } else {
            $iframeHtmlBody.animate({scrollTop: top + 20}, 0);
        }
    },

    /**
     * Navigate to module on
     * sidebar links click
     */
    navigateToAnchor: function($elem) {

        // Shutdown this feature in Chrome.
        // Chrome have a know issue with file protocol and iframe comunication.
        // It is not supported so we should not raise errors.

        if(this.isChromeAndFileProtocol()) return false;

        var top = this.$iframeContent.find('section' + $elem.attr('href')).offset().top + 50;

        // Use ! to prevent de default browser behavior of anchor navigation
        window.location.hash = '!' + $elem.attr('href').replace('#', '');

        this.$iframeContent.find('html, body').animate({scrollTop: top}, 800);
    },
    sidebarOpen: function() {
        this.$body.addClass('opened');
    },
    sidebarClose: function() {
        this.$body.removeClass('opened');
    },

    /**
     * Leave or close the sidebar
     * if the window is small
     */
    sidebarResizeHandler: function() {
        if ($(window).width() <= 1220) {
            this.sidebarClose();
        } else {
            this.sidebarOpen();
        }
    },
    sidebarSetup: function() {

        // Shutdown this feature in Chrome.
        // Chrome have a know issue with file protocol and iframe comunication.
        // It is not supported so we should not raise errors.
        // if(this.isChromeAndFileProtocol()) {
        //     this.$sidebarContent.remove();
        //     this.$sidebarToggle.remove();
        //     return false;
        // }

        if ($(window).width() >= 1220) {
            this.sidebarOpen();
        }
    },
    setActiveSidebarLinkOnClick: function($elem) {
        this.$body.addClass(this.sidebarLinkWasClickedClass);
        this.$sidebarLinks.removeClass(this.sidebarActiveLinkClass);
        $elem.addClass(this.sidebarActiveLinkClass);
    }
  • Вопрос задан
  • 4135 просмотров
Пригласить эксперта
Ответы на вопрос 1
Austin_Powers
@Austin_Powers
Web developer (Symfony, Go, Vue.js)
Это означает, что this.$iframeContent == undefined
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы