Issue #634Opened December 13, 2017by HarshOB0 reactions

How can I pass content with script?

Question

I made custom component like this way and used script as well

bm.add('test-block', {

    label: 'Test block',
    attributes: {
        class: 'fa fa-text'
    },
    content: {
        script: "console.log('the element', this)",
        content: "<h1>hello 123</h1>",
        // Add some style just to make the component visible
        style: {
            width: '100px',
            height: '100px',
            'background-color': 'red',
        }
    }
});

then script is working fine but I am not able to select component. Is there any other way to write content with script?

Answers (3)

artfDecember 13, 20170 reactions

change this components: "<h1>hello 123</h1>",

HarshOBDecember 14, 20170 reactions

I didn't get traits if I use script while creating a custom component. Is there any problem with traits?

artfDecember 14, 20170 reactions

well, there are no traits inside your block... If you're trying instead to use a custom component you have to set the type

content: {
        type: 'your-component-type',
        script: "console.log('the element', this)",
        content: "<h1>hello 123</h1>",

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.