[QUESTION]: Integrate select2 UI element into traits
Question
I'm new to grapesJS ... Great tool.I have a few questions about traits. I followed this tutorial https://grapesjs.com/docs/modules/Traits.html#define-new-trait-type because I have to overwrite how href is generated. The example is great for me with few modifications. I I want to replace ....
<select multiple="multiple"> <option value="option"></option> ....... </select>

with select2 tagging. But I need something like onPostRender/afterRender to initialize the select2 component when the DOM is present
The available methods by the example are
createInput, onEvent, onUpdate
Another thing to trigger onEvent from select2
tagListElement.on('select2:select', function (evt) { // trigger trait onEvent method });
Can someone help with this?
Answers (2)
You can do this:
tagListElement.on('select2:select', e => this.onChange(e)); // onChange will trigger the onEvent properly
@artf thanks
Can you help with first part of the question I need something like onPostRender/afterRender to initialize the select2 component when the DOM is present somthing after createInput method
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2149
[QUESTIONS] Create checkbox(input) in define new trait
How to make a checkbox input type in define new trait (https://grapesjs.com/docs/modules/Traits.html#define-new-trait-type), I have made it...
Issue #3574
QUESTION: adding traits are not picked up by trait manager.
Following example from docs . Is there further configurtion to make new traitsa show for elements? The example using the input does not run...
Issue #1894
[BUG] Custom Trait documentation example doesn't work
Specifically this: https://grapesjs.com/docs/modules/Traits.html#define-new-trait-type First of all, the keyUp event references onChange wh...
Issue #1869
[QUESTION] how to add extra field in input traits
Hi, I want to add the new field in default input traits. for example:- i need to add {label: binding, name:binding} in already exist input...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.