Issue #2530💬 AnsweredOpened January 24, 2020by alemenciones1 reactions

How to drag parent component from selectable child

快速解答by alemenciones1

thanks man, but, i was looking for something like this (just for absolute mode) editor.on("run:tlb-move:before", (targetCollection) => { // Obtengo referencias al componente seleccionado var target = targetCollection.target; var el = target.view.el; //Verifico si tengo un componente padre que me interese var component...

Read full answer below ↓

Question

i have a component type "table" and i find move this table draging her inner components (selectables/stylables) (th, td, ...) this is posible? thanks a lots

Answers (2)

alemencionesJanuary 27, 2020
代码片段TEXT
thanks man, but, i was looking for something like this (just for absolute mode)

`
editor.on("run:tlb-move:before", (targetCollection) => {

       // Obtengo referencias al componente seleccionado
        var target = targetCollection.target;
        var el = target.view.el;

        //Verifico si tengo un componente padre que me interese
        var component = !!el.closest("table") ? "table" : !!el.closest("form") ? !!el.closest("form").attributes["data-ic-profiling-form"] ? "profiling-form" : "form" :  null;

        //Si tengo padre y el hijo no es arrastrable
        if (component && !target.get("draggable")) {

            //functión para recorrer los componentes padres
            var findParentContainerComponent = parent => {

                //Si estoy parado en el padre actualizo el drag-target
                if (parent.get("type") === component) {

                    //Actualizo el target y detengo el bucle
                    targetCollection.target = parent;
                    return ;
                }

                //Busco al padre del elemento actual
                findParentContainerComponent(parent.parent());
            };

            //Busco y selecciono el componente padre que me interesa
            findParentContainerComponent(target);

        }
    });
`
pouyamiralayiJanuary 25, 2020

@alemenciones Select parent using the arrow icon:

arrow

then drag parent like below:

plus

Cheers!

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.