On this.components() Error : Uncaught TypeError: Cannot read property 'each' of undefined
@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)
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)
@artf can you please let me know what am I doing wrong here?
@krunal039 follow the issue template please
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.
Issue #1925
ColorPicker pallete empty value problem
We have this error: "Cannot read property 'getAlpha' of null" when i set the property allowEmpty in true. Can you check this? I'm trying th...
Issue #1614
[Bug]: adding css variables as style manager property
trying to add css variable to style manager causing error: Uncaught TypeError: Cannot read property 'toUpperCase' of undefined fiddle Am i...
Issue #439
unstable
In my machine grapesjs is unstable. Generally at first request throws below error. After refreshing one or two times, it works. Bug exists...
Issue #1186
[Bug] Number trait returns 'undefined'
Hello, it's either a bug or a question, i don't know yet. I defined a new component with - beside others - a number trait, as you can see o...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins β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.