Issue #1643Opened December 10, 2018by alialrabi0 reactions

Render New Html to editor with Action of Traits

Question

I create New custom Tool with (default html) when draged , and i also create traits for this component when i click on checkbox excuting function (do stuff())>> the result of this function new html i want to append it to editor , i have used to select by class ( in jquery ) from editor( the default html to append to it ) but not work , how can i render new html to editor on action , and how can to select some html by class or id to append to it some new htmldata

Code SnippetTEXT
=============
I create my new custom tool by:
         this.editor.BlockManager.add('sidebar', {
             id: 'sidebar',
            label: 'SideBar',
            attributes: {class:'fa fa-bullhorn'},
            content: {
                style: {color: 'black'},
                type: 'sidebar',
                         }

        });
=============
and this to add default render html and  traits and excuting some functions on listen to checkbox  :

i want to apppent newDom html  var to the editor on action 

 comps.addType('sidebar', {
            model: defaultModel.extend({
      init() {
                 
                    this.listenTo(this, 'change:business', this.doStuff);
                    this.listenTo(this, 'change:confrences', this.doStuff);
                    this.listenTo(this, 'change:Nuclear', this.doStuff);
                   },

                doStuff() {
        // some java script method 
//the result new html
                 },


                defaults: Object.assign({}, defaultModel.prototype.defaults, {
                    traits: [
                        'Title',

                         // this.catogrylist   ,
                        {
                            type: 'checkbox',
                            label:'business',
                            name:'business',
                            changeProp: 1,


                        },
                        {
                            type: 'checkbox',
                            label:'confrences',
                            name:'confrences',
                            changeProp: 1,

                        },
                        {
                            type: 'checkbox',
                            label:'Nuclear',
                            name:'Nuclear',
                            changeProp: 1,

                        },

                    ],


                }),
            }, {
                isComponent: function(el) {
                    if(el.tagName == 'div'){
                        return {type: 'sidebar'};
                    }
                },
            }),

            view: defaultView.extend({
           tagName: 'div',
                                                                render: function () {
                                                               
                                                                    this.el.innerHTML = ` <div class="categories" style="width:15%;height: 100%;background-color: #4b5257"></div>
            `;
            
                                                                   return this;
                                                                },
                                                            }),

        });

Answers (2)

lock[bot]December 12, 20190 reactions

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

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.