Issue #1627πŸ’¬ AnsweredOpened December 4, 2018by SeongwoonHong0 reactions

$('.gjs-trt-traits') is null (trying to have 'Settings' sector under the style)

Quick answerby artf

Traits are not created by default if not requested, indeed I'm doing this in the demo https://github.com/artf/grapesjs/blob/gh-pages/demo.html#L1407-L1408

Read full answer below ↓

Question

Code SnippetTEXT
Hi,
I'm using webpage preset and trying to have Settings sector under Style like the demo by doing this (exactly the same as demo.html) but the problem that i have is $('.gjs-trt-traits') this is null therefore, if I toggle 'Settings' under Styles, it is empty. Please let me know..Thank you!


    var traitsSector = $('<div class="gjs-sm-sector no-select">'+
    '<div class="gjs-sm-title"><span class="icon-settings fa fa-cog"></span> Settings</div>' +
    '<div class="gjs-sm-properties" style="display: none;"></div></div>');
    var traitsProps = traitsSector.find('.gjs-sm-properties');
    traitsProps.append($('.gjs-trt-traits'));
    $('.gjs-sm-sectors').before(traitsSector);
    traitsSector.find('.gjs-sm-title').on('click', function(){
      var traitStyle = traitsProps.get(0).style;
      var hidden = traitStyle.display == 'none';
      if (hidden) {
        traitStyle.display = 'block';
      } else {
        traitStyle.display = 'none';
      }

Answers (2)

lock[bot]β€’ December 7, 2019

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

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

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.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.