Issue #400Opened October 10, 2017by sanjeevSavitr0 reactions

Hide An element in commands

Question

Hi,

I want to hide a particular element when ever we click a toolbar button

Code SnippetTEXT
commands:     {
          defaults: [{
            id:   'sub_menu_item',
            run: function(editor, senderBtn){
				// I want to hide "photostack-1" element
				????
				????
				????
            },
          }],
      }
	  
	  
	  
	  
	  var domc = editor.DomComponents;
	  domc.addType('banner_gallery_portion',
      {
        model: defaultModel.extend({
            defaults: Object.assign({},
              defaultModel.prototype.defaults,
              {
				...
                toolbar: [{
                           attributes: {class: 'fa fa-arrows'},
                           command: 'tlb-move',
                         },{
                           attributes: {class: 'fa fa-plus'},
                           //command: 'tlb-clone',
                             command:'sub_menu_item',
                        }],
				...
                }
              })
          },
          ),

        view: defaultType.view.extend({
                  init() {
        this.listenTo(this.model, 'change:startfrom change:endText', this.updateScript);
        const comps = this.model.get('components');

        // Add a basic countdown template if it's not yet initialized
        if (!comps.length) {
          comps.reset();
          comps.add(`
      		<div class="container">
				<section id="photostack-1" class="photostack photostack-transition photostack-perspective">
				....
				....
				</section>
			</div>

                `
            );
        }

      },

Answers (3)

artfOctober 11, 20170 reactions

You can access the element from the model

const selectedModel = editor.getSelected();
const elem = selectedModel.view.el.querySelector('#photostack-1');
elem.style.display = 'none';
sanjeevSavitrOctober 13, 20170 reactions

Thanks..

lock[bot]September 18, 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.