Issue #1448đź’¬ AnsweredOpened September 21, 2018by prestonkscott1 reactions

Child component not selectable when using custom view

Quick answerby artf❤ 1

If you add elements via View you can't select them, only Models can be selectable Read this page https://grapesjs.com/docs/modules/Components.html you also create new types without isComponent

Read full answer below ↓

Question

I'm trying to create a custom component that creates it's own view with nested HTML. I do not want this HTML to be rendered as a component so I use (using jQuery) view: defaultType.view.extend({ init: function () { $(this.el).html('<div class="container"></div>'); }, getChildrenSelector: function () { return '.container'; }, }) But, if I add child components, they are not selectable through the editor. They can only be selected through the Layer panel. I've created a jsFiddle of the issue: https://jsfiddle.net/pscott/72xgqkdy/ I've found that if I remove the 'pointer-events' style from the pa...

Answers (3)

prestonkscott• October 2, 2018

@artf I understand how to use isComponent. I will be using fromElement: false so it's not required for how I intend to use grapes. I do not want the elements added to the view to be selected, I do however want nested components to be selectable. Currently they are not. For example, if I render this...

artf• October 4, 2018

Ok, now I got it. The getChildrenContainer should work as you expect, I'll just try to remove those pointer-events stuff and make the hover work more like the select. BTW you don't need jquery, grapesjs under the hood uses cash (which has jquery-like API) so you can do: this.$el.html('...'); There...

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 →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.