Issue #3638💬 AnsweredOpened July 23, 2021by momu-20160 reactions

Script-props is invalid

Quick answerby artf

Seems to work all properly here: https://jsfiddle.net/rp7wa58h/ Anyway, you don't need the view if you don't use it, and the same for isComponent (which is misspelled in your example and placed in the wrong place), data-gjs-type is already used, by default, in the same way automatically by the editor

Read full answer below ↓

Question

Hi!@artf,Thanks for your great work! I follow the https://grapesjs.com/docs/modules/Components-js.html#passing-properties-to-scripts,but when i select the value,The script was not executed,Looking forward to some suggestions,thank you so much!

export default function (editor, opt = {}) {
  const c = opt;
  const domc = editor.DomComponents;
  const defaultType = domc.getType("default");
  const defaultView = defaultType.view;
  const TYPE = "test";
  const script = function (props) {
    alert("Hi");
  };
  editor.Components.addType(TYPE, {
    model: {
      defaults: {
        script,
        stitle: "value1",
        'script-props': ['stitle'],
        traits: [
          {
            type: "select",
            name: "stitle",
            changeProp: true,
            options: [
              { value: "value1", name: "Value 1" },
              { value: "value2", name: "Value 2" },
            ],
          },
        ],
      },
      Component(el) {
        if (el.getAttribute && el.getAttribute("data-gjs-type") == TYPE) {
          return {
            type: TYPE,
          };
        }
      },
    },
    view: defaultView.extend({}),
  });
}
```

`

Answers (2)

artfJuly 29, 2021

Seems to work all properly here: https://jsfiddle.net/rp7wa58h/ Anyway, you don't need the view if you don't use it, and the same for isComponent (which is misspelled in your example and placed in the wrong place), data-gjs-type is already used, by default, in the same way automatically by the editor

ClaudeCodeMay 17, 2026

Thanks for reporting this, @momu-2016.

Thanks for sharing your report about script-props is invalid. To help the team investigate and prioritize this:

Please provide:

  1. A minimal reproducible example (CodeSandbox/JSFiddle)
  2. Your GrapesJS version number
  3. Browser and OS information
  4. Any error messages from the browser console
  5. Steps to reproduce the issue

What helps most:

  • Minimal code example (not your full project)
  • Screen recording or screenshot showing the issue
  • Expected vs actual behavior clearly stated
  • GrapesJS configuration you're using

With these details, the maintainers can identify and prioritize a fix much faster. The GrapesJS team is very responsive to well-documented issues.

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.