Issue #1520πŸ’¬ AnsweredOpened October 16, 2018by krunal0390 reactions

On this.components() Error : Uncaught TypeError: Cannot read property 'each' of undefined

Quick answerby krunal039

@artf can you please let me know what am I doing wrong here?

Read full answer below ↓

Question

Get below error for this.components() not sure if it is bug or I am doing something wrong.

Uncaught TypeError: Cannot read property 'each' of undefined at R.i.countChildren (grapes.min.js:formatted:16228) at R.i.template (grapes.min.js:formatted:16093) at R.i.render (grapes.min.js:formatted:16248) at R.i.addToCollection (grapes.min.js:formatted:16332) at R.i.addTo (grapes.min.js:formatted:16317)

Code SnippetTEXT
at y (grapes.min.js:formatted:284)
    at m (grapes.min.js:formatted:262)
    at d (grapes.min.js:formatted:128)
    at R.i.u.trigger (grapes.min.js:formatted:253)
    at R.i._onModelEvent (grapes.min.js:formatted:815)

`
var createSliderComponent = function (comps, defaultModel, defaultView) {

        var defaultType = comps.getType('default');
        var defaultModel = defaultType.model;
        var defaultView = defaultType.view;

        comps.addType(sliderType, {
            // Define the Model
            model: defaultModel.extend({
                // Extend default properties
                defaults: Object.assign({}, defaultModel.prototype.defaults, {

                    type: sliderType,
                    tagName: 'div',
                    draggable: false,
                    droppable: false,
                    copyable: false,
                    removable: false,
                    stylable: false,
                    copyable: false,
                    resizable: false,
                    editable: true,
                    content : '<div class="slider-left-part"><h2>Sample Title</h2><div class="slider-title">Lorem Ipsum</div><div class="slider-description"></div><div class="slider-link"><a href="">Link</a></div></div><div class="slider-right-part"><img class="slider-image" src="https://via.placeholder.com/503x300"></div>',
                    attributes: {
                        'class': 'slider-container'
                    }

                }),
                initialize() {
                    // If I have no inner components
                    if (this.components() && !this.components().length) {
                        debugger;
                        this.components(this.get("content"));
                    }
                }
            }, {
                isComponent(el) {
                    if (el.getAttribute &&
                        el.getAttribute('data-gjs-type') == sliderType) {
                        return {
                            type: sliderType
                        };
                    }
                }
            }),
            // Define the View
            view: defaultView.extend({
                tagName: 'div',
                render(args) {
                    defaultView.prototype.render.apply(this, args);
                    return this;
                  }
            })
        });
    };`

Answers (3)

krunal039β€’ October 19, 2018

@artf can you please let me know what am I doing wrong here?

artfβ€’ October 19, 2018

@krunal039 follow the issue template please

lock[bot]β€’ October 19, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

Premium plugins ship with support, regular updates, and production-ready features β€” save days of integration work.

Browse premium plugins β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.