Slider with % AND dynamic value - can't seem to get prettify to work
See original GitHub issueI have an existing slider with data attributes like this:
min: 0, max: 100, step: 1, postfix: '%'
I would like to have the slider display like this (I manually edited the HTML to show this):

The page has multiple sliders in a nested form so each has an associated base multiplier amount i.e. $10,000 x 50% and the slider handle would dynamically update.
My thought here is that I do this:
min: 0, max: 100, step: 1, value: 10000
then I tried this:
$(".myclass").ionRangeSlider()({
min: 0,
max: 100,
step: 1,
value: $(this).data('value'),
prettify: function(n) {
return n + '%' + ' ($' + value * n / 100 + ')';
}
});
and get:

I will admit to not being the most proficient at JS so I may be missing something minor / obvious here. After some digging I think I am not accessing the value data attribute. I also tried this (and realized I need to turn my string to a float):
$(".myclass").ionRangeSlider()({
min: 0,
max: 100,
step: 1,
prettify: function(n) {
return n + '%' + ' ($' + parseFloat($(this).data('value')) * n / 100 + ')';
}
});
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
VS-Code Prettier Format On Save doesn't work - Stack Overflow
Follow these steps: CTRL + SHIFT + P; Format Document (in pop-up bar); Select Format Document; Select Configure Default Formatter.
Read more >Slider not working with dynamic values. #985 - GitHub
Slider (p-slider) is working fine with dynamic values like this But when ... When It's at the left end, the value should be...
Read more >Options - Prettier
Prettier's printWidth option does not work the same way. It is not the hard upper allowed line length limit. It is a way...
Read more >What is a Layer and How to Use it in Smart Slider 3?
Transition layers can be used to make the slides prettier, and more interactive. This layer has two image fields where you can set...
Read more >How to configure Prettier and VSCode - Gleb Bahmutov
To use the Prettier we have just installed from VSCode we need to install ... like ESLint can catch the assignment to a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yes, I will think about it.
I ended up settling on this (bac is my data attribute value):