Issue #2283Opened September 20, 2019by gagan3480 reactions

[Question] How do I pass resizable onMove function in data-gjs-resizable attribute

Question

Code SnippetTEXT
onStart event is working fine while creating component but I want to add it while creating block. Here is  my code: 

const keyWidth = 'flex-basis';
const step = 0.1;
const minDim = 1;
const currentUnit = 1;

const resizerRight = {
        tl: 0, tc: 0, tr: 0, cl: 0, bl: 0, br: 0, cr: 1, bc: 0, keyWidth, currentUnit, minDim, step }

const attrsToString = attrs => {
        const result = [];

        for (let key in attrs) {
            let value = attrs[key];
            const toParse = value instanceof Array || value instanceof Object;
            value = toParse ? JSON.stringify(value) : value;
            result.push(`${key}=${toParse ? `'${value}'` : `"${value}"`}`);
        }

        return result.length ? ` ${result.join(' ')}` : '';
    }

const attrsCell = attrsToString(colAttr);

if (c.blocks.grid) {
        bm.add('grid', {
            label: `
            <div class="gjs-block-label">Grid</div>
        `,
            category: 'Basic',
            attributes: { class: 'gjs-fonts gjs-f-b3' },
            content: `
            <div class="container">
                <div class="row" data-gjs-selectable="false" data-gjs-hoverable="false" data-gjs-droppable="false" >
                    <div ${attrsCell}></div>
                    <div ${attrsCell}></div>
                    <div ${attrsCell}></div>
                </div>
            </div>
        `
        });
    }

Answers (1)

artfSeptember 28, 20190 reactions

You can write content as Component Definition instead of the HTML string

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.