Traits type : button not working
Hi @Soharab-Shaikh you have to pass the command option (will be executed on click):
Read full answer below ↓Question
Hi, @artf When I try to use button type traits. It does not fire any function. Can you please help me with this. Can you please share an example of new traits type creation like "Button", not the "Content" one. traits: [ { type: 'button', label: 'Submit', name: 'blogsubmit', changeProp: 1 } ] .... init() { this.listenTo(this, 'change:blogsubmit', this.changeFilter); } ..... For new traits type creation, I am trying editor.TraitManager.addType('button', { events: { 'keyup' : 'onChange' // what should we use in this part? }, getInputEl: function () { if (!this.inputEl) { var x = document.create...
Answers (2)
Hi @Soharab-Shaikh you have to pass the command option (will be executed on click):
traits: [
{
...
type: 'button',
command: 'COMMAND-ID',
// or like a function
command: editor => {
const selected = editor.getSelected();
// do something...
},
}
]
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.
Issue #1817
Change HTML content while block is render in editor
Hello @artf I have one block into block manager like As per above script inside the block, i want to add dynamic HTML content while this bl...
Issue #558
Help: Can you please give an example of Chart.js as a block in grapesjs.
@artf can you please give one complete example of a chart using chart.js with traits for changing the colour, values & Data Points.? It wou...
Issue #1998
Extending Link component not working properly.
hello @hello @artf I am trying to extend the link component and add new traits like href and target the code is given below. `function load...
Issue #1720
[QUESTION] How to add the button in custom traits
Hi, I try to add a button to my custom traits for my custom blocks but its not working fine as expected and also need to know how to call t...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →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.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.