Issue #3524Opened June 8, 2021by iteniel0 reactions

[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> Selection_208

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)

artfJune 10, 20210 reactions

You can do this:

tagListElement.on('select2:select', e => this.onChange(e)); // onChange will trigger the onEvent properly
itenielJune 10, 20210 reactions

@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.

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.