Range slider not working
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)
There is no built-in range trait, you have to create one first
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1493
[QUESTION] render() works on the first time but not on subsequent calls
Hello, I've created a custom component that shows images using background-image on a <div> instead of using an <img> element. It's mostly w...
Issue #2511
How to open a sector when selecting a element?
Hello everybody How do i open a selector like general as i select the element. I am new to javascript, but i tried something out like this....
Issue #1113
[QUESTIONS] New trait type is not working with rendered components?
Hello, thanks for the great framework. I'm trying to apply this to my project. I want to add a new trait for existing LINK '<a>' component....
Issue #5334
Selection of custom component type not working in the canvas
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome, Opera, Edge, etc Reproducible demo...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →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.