Issue #1959💬 AnsweredOpened April 10, 2019by trafalmejo0 reactions

Edit innerHTML in a custom button

快速解答by simplecommerce

@trafalmejo Try looking at the way they implement the link component, I think it might help you, not 100% sure though.

Read full answer below ↓

Question

Hi All,

I am trying to change the text in a button component, but I am not able to edit it. I added this type:

comps.addType('button', {
  // Define the Model
  model: defaultModel.extend({
    // Extend default properties
    defaults: Object.assign({}, defaultModel.prototype.defaults, {
    	style: {
    		width: '130px',
    		height: '50px',
    	},
      // Can't drop other elements inside it
      droppable: false,
      resizable: true,
      editable: true,
      }),
  },

I included the editable: true parameter but is not working And add the button to the Component Manager

 editor.BlockManager.add('button', {
 	label: 'Button',
 	attributes: { class:'gjs-fonts gjs-f-b1'},
 	category: 'Basic',
 	content: '<button type="button">Click Me!</button>'
 })

Is there any way to workaround this? Thanks!

Answers (3)

simplecommerceApril 10, 2019

@trafalmejo Try looking at the way they implement the link component, I think it might help you, not 100% sure though.

artfApril 11, 2019

You should extend the text component

lock[bot]April 15, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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.