Need a feature to integrate modal form
Hello @suchiitsme i think you can implement a component type.
Read full answer below ↓Question
[FEATURE REQUESTS] I have to add block which should a open a modal with form fields. Based on the form data selected I have to generate a html string and insert it to editor. and on click /double click of the component, modal should open again with the form details. How can I do this? Please help.
Answers (3)
Hello @suchiitsme i think you can implement a component type.
comps.addType('custom-form', {
model: defaultModel.extend({
defaults: {
...defaultModel.prototype.defaults,
removable: false,
draggable: false,
copyable: false,
editable: true,
propagate: ["removable", "draggable", "copyable", "editable"]}
}, {
isComponent: function(el){
result = "";
if (el.tagName === "form" && el.getAttribute("class").toString().indexOf("customForm") > -1) {
result = {type: "custom-form"}
}
return result
}
}),
view: defaultView.extend({
defaults: {...defaultView.prototype.defaults},
events: {
click: function(event) {
alert("Do anything")
}
}
}
}),
});
Hello @suchiitsme i think you can implement a component type.
comps.addType('custom-form', { model: defaultModel.extend({ defaults: { ...defaultModel.prototype.defaults, removable: false, draggable: false, copyable: false, editable: true, propagate: ["removable", "draggable", "copyable", "editable"]} }, { isComponent: function(el){ result = ""; if (el.tagName === "form" && el.getAttribute("class").toString().indexOf("customForm") > -1) { result = {type: "custom-form"} } return result } }), view: defaultView.extend({ defaults: {...defaultView.prototype.defaults}, events: { click: function(event) { alert("Do anything") } } } }), });
Thank you. I will give a try!!
Hi How do I link this to block?
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3135
[Help Wanted] How to easily override existing component ?
For example, I want to add a double click event handler on the default video component to open the assets manager. My basic idea was to get...
Issue #3239
[Question] How to update attribute/properties dynamically from Component Script?
We have a use case where we want to insert charts dynamically using Highcharts Editor. I have created a component, which on drag and drop,...
Issue #2129
[Question] how to append a button inside default modal and catch it's click event
I want a form inside a modal (using the default modal ), on click of the submit button make an ajax call. I have created a new component wh...
Issue #3124
FEAT: component:clicked / dbclicked event
Hi, i am trying to use video component to upload in the assets manager. And I realize I can leverage editor event component:selected to do...
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.
Tutorial
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
Tutorial
GrapesJS Inline RTE Plugins Update: CKEditor 5 v0.1.4 and Froala Inline Text Editor
CKEditor 5 Inline for GrapesJS v0.1.4 fixes Studio SDK toolbar clipping, iframe injection and link balloon bugs. Compare with Froala Inline — both $69.
Tutorial
Embed GrapesJS in Your SaaS: A Weekend Guide
Embed GrapesJS in your SaaS and ship a white-label page builder over a weekend. Honest tradeoffs, real code, and the plugins that close the UX gap.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.