Issue #2980💬 AnsweredOpened August 27, 2020by ikenderham0 reactions

Range slider not working

快速解答by ikenderham

https://jsfiddle.net/psrdmx4c/

Read full answer below ↓

Question

Hello everybody

I am trying to make a range slider inside a trait, where i can change a div height. I created a new component and inside of it i created a trait.

I tried to make a solution with a selectbox that seems working. But now i will try to do that with a range slider, but i really dont know how to make it. Its not working and not changing the height.

Hope anyone can help me solve this

editor.DomComponents.addType('spacercomp', {
    model: {
      defaults: {
          toolbar: [{
        attributes: {class: 'fa fa-arrows'},
        command: 'tlb-move',
      },
      {
        attributes: {class: 'fa fa-arrow-up'},
        command: 'moveUp-command',
      },
      {
        attributes: {class: 'fa fa-arrow-down'},
        command: 'moveDown-command',
      },{
        attributes: {class: 'fa fa-clone'},
        command: 'tlb-clone',
      },{
        attributes: {class: 'fa fa-arrows'},
        command: 'tlb-move',
      },{
        attributes: {class: 'fa fa-trash'},
        command: 'tlb-delete',
      }],
       traits: [
          // Strings are automatically converted to text types
			{// this is working. 
            type: 'select', // Type of the trait
            label: 'Højde', // The label you will see in Settings
            name: 'style', // The name of the attribute/property to use on component
            unit: 'px',
            placeholder: 'Vælg højde',
            options: [
              { value: 'height:10px', name: '10px'},
              { value: 'height:20px;font-size:20px;', name: '20px'},
              { value: 'height:30px', name: '30px'},
              { value: 'height:40px', name: '40px'},
            ]
          },{// this is not working.. what i am missing?
            label: 'Højde', // The label you will see in Settings
            name: 'style', // The name of the attribute/property to use on component
            type: 'range',
            min:'10',
            max:'100',
          }


          ],

      },
    },
});

Answers (2)

artfAugust 28, 2020

There is no built-in range trait, you have to create one first

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 →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.