Issue #1520Opened October 16, 2018by krunal0390 reactions

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

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)

krunal039October 19, 20180 reactions

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

artfOctober 19, 20180 reactions

@krunal039 follow the issue template please

lock[bot]October 19, 20190 reactions

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.